/* Página pública */
:root {
    --bg: #f1f5f9;
    --bg-accent: #e0e7ff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --group-accent: #3b82f6;
    --sub-accent: #6366f1;
    --header-h: 60px;
    --font: 'Plus Jakarta Sans', system-ui, sans-serif;
    --max-w: 720px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.12), transparent),
        linear-gradient(180deg, var(--bg) 0%, #f8fafc 100%);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Header fixo */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.site-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    white-space: nowrap;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, box-shadow 0.2s, color 0.2s, background 0.2s;
}

.site-home-btn:hover {
    color: var(--primary);
    border-color: #c7d2fe;
    background: var(--primary-soft);
    box-shadow: var(--shadow-md);
}

.site-home-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.search-wrap {
    flex-shrink: 0;
}

.search-box {
    display: flex;
    align-items: center;
    height: 42px;
    width: 42px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    cursor: text;
    transition:
        width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.25s ease,
        border-color 0.25s ease;
    box-shadow: var(--shadow);
}

.search-box:hover,
.search-box:focus-within,
.search-box.is-expanded {
    width: min(280px, calc(100vw - 12rem));
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.search-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color 0.2s;
}

.search-box:hover .search-icon,
.search-box:focus-within .search-icon,
.search-box.is-expanded .search-icon {
    color: var(--primary);
}

.search-input {
    flex: 1;
    min-width: 0;
    width: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    opacity: 0;
    transition: opacity 0.25s ease 0.05s;
}

.search-input::placeholder {
    color: var(--muted);
}

.search-input:focus {
    outline: none;
}

.search-box:hover .search-input,
.search-box:focus-within .search-input,
.search-box.is-expanded .search-input {
    width: 100%;
    padding-right: 1rem;
    opacity: 1;
}

.search-input:disabled {
    cursor: not-allowed;
}

/* Main */
.site-main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: calc(var(--header-h) + 1.5rem) 1.25rem 3rem;
}

/* Filtros */
.filters-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filter-field {
    flex: 1;
    min-width: 140px;
}

.filter-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.375rem;
}

.filter-select {
    width: 100%;
    height: 42px;
    padding: 0 2rem 0 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.625rem center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:hover {
    border-color: var(--border-strong);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.filter-clear {
    flex-shrink: 0;
    height: 42px;
    padding: 0 1rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.filter-clear:hover {
    background: #e0e7ff;
    color: var(--primary-hover);
}

.filter-clear[hidden] {
    display: none;
}

/* Grupos */
.links-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.group-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.group-section.is-hidden {
    display: none;
}

.group-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1.125rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--group-accent);
}

.group-header-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: var(--group-accent);
    border-radius: 8px;
    flex-shrink: 0;
}

.group-title {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.group-body {
    padding: 0.75rem 1rem 1rem;
}

.group-body.is-hidden {
    display: none;
}

.subgroup-block {
    margin-bottom: 1rem;
}

.subgroup-block:last-child {
    margin-bottom: 0;
}

.subgroup-block.is-hidden {
    display: none;
}

.subgroup-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub-accent);
    margin-bottom: 0.625rem;
    padding-left: 0.25rem;
}

.subgroup-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sub-accent);
    flex-shrink: 0;
}

.links-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.link-item.is-hidden {
    display: none;
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    transition:
        border-color 0.2s,
        background 0.2s,
        box-shadow 0.2s,
        transform 0.15s;
}

.link-card:hover {
    background: var(--surface);
    border-color: #a5b4fc;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.link-card:active {
    transform: translateY(0);
}

.link-card-main {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.link-text {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.35;
}

.link-breadcrumb {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-arrow {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.link-card:hover .link-arrow {
    background: var(--primary);
    color: #fff;
    transform: translate(2px, -2px);
}

.empty-state,
.no-results {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.85;
}

.no-results {
    margin-top: 0.5rem;
}

.hidden {
    display: none !important;
}

/* Página de grupo compartilhado */
.shared-group-banner {
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left: 4px solid var(--group-accent);
}

.shared-group-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--group-accent);
    margin-bottom: 0.25rem;
}

.shared-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.shared-group-banner-protected {
    border-left-color: var(--primary);
}

.icon-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    vertical-align: middle;
}

.group-lock-badge,
.link-lock {
    margin-right: 0;
}

.link-lock {
    margin-right: 0.35rem;
}

.group-header-protected .group-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.group-protected-notice {
    margin: 0 0 1.25rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.group-protected-notice p {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.btn-unlock-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    text-decoration: none;
}

.btn-unlock-group:hover {
    opacity: 0.92;
}

.shared-group-expiry {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.filters-panel-compact {
    margin-bottom: 1.25rem;
}

/* Link protegido */
.unlock-icon .icon-lock {
    font-size: 2rem !important;
}

.link-card-protected {
    border-color: #c7d2fe;
}

/* Página de desbloqueio */
.unlock-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.unlock-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.unlock-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 14px;
}

.unlock-card h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.unlock-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.unlock-error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.unlock-hint {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.unlock-form {
    text-align: left;
    margin-bottom: 1rem;
}

.unlock-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.unlock-input {
    width: 100%;
    height: 44px;
    padding: 0 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9375rem;
    margin-bottom: 0.875rem;
}

.unlock-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.unlock-btn {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.unlock-btn:hover {
    background: var(--primary-hover);
}

.unlock-back {
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
}

.unlock-back:hover {
    color: var(--primary);
}

@media (max-width: 560px) {
    .site-header {
        padding: 0 1rem;
    }

    .site-home-btn {
        font-size: 0.875rem;
        padding: 0.4375rem 0.875rem;
    }

    .search-box:hover,
    .search-box:focus-within,
    .search-box.is-expanded {
        width: min(200px, calc(100vw - 10rem));
    }

    .site-main {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-field {
        min-width: 100%;
    }

    .filter-clear {
        width: 100%;
    }

    .link-breadcrumb {
        display: none;
    }
}
