/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: #333;
    background-color: #f8fafc;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Header */
.header {
    background-color: #ffffff;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    gap: 1rem;
    min-width: 0;
}

/* Logo */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #2563eb;
    font-weight: 700;
    font-size: 1.8rem;
    transition: transform 0.2s ease;
    min-width: 0;
}

.logo:hover {
    transform: scale(1.02);
}

.logo-image {
    display: block;
    width: auto;
    height: 54px;
    object-fit: contain;
}

.logo-icon {
    font-size: 2rem;
    margin-right: 0.5rem;
}

.logo-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    white-space: nowrap;
}

.tagline {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
    letter-spacing: 0.05em;
}

/* Barra di ricerca */
.search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
    min-width: 0;
}

.search-form {
    width: 100%;
}

.search-input-group {
    display: flex;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-input-group:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.5rem;
    border: none;
    font-size: 1rem;
    background: transparent;
    color: #334155;
}

.search-input:focus {
    outline: none;
}

.search-button {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    color: white;
    border: none;
    padding: 0 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-button:hover {
    background: linear-gradient(90deg, #1d4ed8, #2563eb);
}

.search-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
}

.search-hint em {
    font-style: normal;
    color: #3b82f6;
    font-weight: 500;
}

/* Menu utente */
.user-menu {
    display: flex;
    gap: 1.5rem;
    min-width: 0;
}

.user-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    padding: 0.5rem;
    border-radius: 8px;
}

.user-menu-item-button {
    border: none;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.user-menu-item-static {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.user-menu-item:hover {
    color: #2563eb;
    background-color: #f1f5f9;
}

.user-menu-item-static:hover {
    color: #2563eb;
    background-color: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

.user-menu-item-static:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.16);
}

.user-menu-item i {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.top-categories-bar {
    position: sticky;
    top: 94px;
    z-index: 990;
    background: rgba(248, 250, 252, 0.96);
    border-bottom: 1px solid #e2e8f0;
    backdrop-filter: blur(10px);
}

.top-categories-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.55rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.top-categories-label {
    flex-shrink: 0;
    color: #475569;
    font-weight: 700;
    font-size: 0.82rem;
}

.top-categories-list {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.top-category-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0.45rem 0.75rem;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #fff;
    color: #2563eb;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.2;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.top-category-link:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateY(-1px);
}

.top-category-link i {
    font-size: 0.8rem;
    color: #f59e0b;
}

body.client-auth-open {
    overflow: hidden;
}

.client-auth-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1400;
    padding: 1rem;
    overflow-y: auto;
}

.client-auth-modal.is-open {
    display: flex;
}

.client-document-modal {
    z-index: 1800;
}

.client-auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
}

.client-auth-dialog {
    position: relative;
    width: min(560px, calc(100vw - 2rem));
    max-width: 100%;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 24px;
    border: 1px solid #dbeafe;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.24);
    padding: 2rem;
    z-index: 1;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.client-auth-dialog-small {
    width: min(500px, calc(100vw - 2rem));
}

.client-auth-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
}

.client-auth-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.client-auth-header p {
    color: #64748b;
    margin-bottom: 1.5rem;
}

.client-auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.client-auth-form {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.client-auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: #475569;
    font-size: 0.95rem;
    min-width: 0;
}

.client-auth-checkbox input {
    width: 18px;
    height: 18px;
}

.client-auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    min-width: 0;
}

.client-auth-field {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.client-auth-field label {
    color: #334155;
    font-weight: 600;
    font-size: 0.95rem;
}

.client-auth-field label span {
    color: #94a3b8;
    font-weight: 500;
}

.client-auth-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0.95rem 1rem;
    font-size: 0.98rem;
    color: #0f172a;
    background: #fff;
}

.client-auth-field input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.client-auth-feedback {
    border-radius: 12px;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
}

.client-auth-feedback.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.client-auth-turnstile {
    display: flex;
    justify-content: flex-start;
    min-width: 0;
}

.client-auth-turnstile:empty {
    display: none;
}

.client-auth-turnstile .turnstile-widget {
    max-width: 100%;
}

.client-auth-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border: none;
    border-radius: 14px;
    padding: 1rem 1.4rem;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.22);
}

.client-auth-submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

@media (max-width: 768px) {
    .header {
        position: relative;
    }

    .header-container {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        padding: 0.85rem 1rem;
        gap: 0.75rem;
        max-width: 100%;
    }

    .logo-container {
        min-width: 0;
    }

    .logo {
        gap: 0.45rem;
        font-size: 1.35rem;
        max-width: 100%;
    }

    .logo-image {
        height: 42px;
        flex-shrink: 0;
    }

    .logo-text {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .tagline {
        display: none;
    }

    .search-container {
        grid-column: 1 / -1;
        order: initial;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .search-input {
        padding: 0.82rem 0.9rem;
        font-size: 0.95rem;
    }

    .search-button {
        width: 48px;
        padding: 0;
        flex-shrink: 0;
    }

    .search-hint {
        display: none;
    }

    .user-menu {
        justify-content: flex-end;
        gap: 0.35rem;
        max-width: 100%;
    }

    .user-menu-item {
        min-width: 40px;
        padding: 0.45rem;
        font-size: 0.72rem;
    }

    .user-menu-item span {
        display: none;
    }

    .user-menu-item i {
        margin-bottom: 0;
        font-size: 1.18rem;
    }

    .top-categories-bar {
        top: 0;
        position: relative;
    }

    .top-categories-container {
        padding: 0.55rem 1rem;
        align-items: flex-start;
        flex-direction: column;
        gap: 0.45rem;
    }

    .top-categories-list {
        width: 100%;
    }

    .client-auth-dialog {
        width: 100%;
        max-height: calc(100dvh - 1rem);
        border-radius: 18px;
        padding: 1.25rem;
    }

    .client-auth-grid {
        grid-template-columns: 1fr;
    }

    .user-menu {
        gap: 0.75rem;
    }
}

@media (max-width: 420px) {
    .client-auth-modal {
        align-items: flex-start;
        padding: 0.5rem;
    }

    .client-auth-dialog {
        width: 100%;
        border-radius: 16px;
        padding: 1rem;
    }

    .client-auth-header h2 {
        font-size: 1.35rem;
        padding-right: 2.5rem;
    }

    .client-auth-header p,
    .client-auth-checkbox,
    .client-auth-field input,
    .client-auth-feedback {
        font-size: 0.9rem;
    }

    .client-auth-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
    }
}

.favorites-panel,
.favorites-confirm-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1450;
}

.favorites-panel.is-open,
.favorites-confirm-modal.is-open {
    display: block;
}

.favorites-panel-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.favorites-panel-dialog {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background: #fff;
    box-shadow: -20px 0 60px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.favorites-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.4rem 1.4rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    flex: 0 0 auto;
    min-width: 0;
}

.favorites-panel-badge {
    display: inline-flex;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.favorites-panel-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.favorites-panel-subtitle {
    margin-top: 0.55rem;
    max-width: 320px;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.55;
}

.favorites-panel-close {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
    flex: 0 0 auto;
}

.favorites-panel-body {
    flex: 1;
    overflow: auto;
    min-height: 0;
    max-height: 100%;
    padding: 0.7rem;
    display: grid;
    gap: 0.6rem;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.favorites-panel-state {
    min-height: 240px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #64748b;
    gap: 0.75rem;
}

.favorites-panel-state i {
    font-size: 1.8rem;
    color: #2563eb;
}

.favorite-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 0.7rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0.65rem;
    background: #fff;
    min-width: 0;
}

.favorite-item-media img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.favorite-item-content {
    display: grid;
    gap: 0.5rem;
    min-width: 0;
}

.favorite-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
    min-width: 0;
}

.favorite-item-top h3 {
    font-size: 0.84rem;
    color: #0f172a;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.favorite-remove-button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #fecaca;
    background: #fff5f5;
    color: #dc2626;
    cursor: pointer;
    flex-shrink: 0;
}

.favorite-price-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.favorite-price-grid div {
    background: #f8fafc;
    border-radius: 10px;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
}

.favorite-price-label {
    display: block;
    font-size: 0.68rem;
    color: #64748b;
    margin-bottom: 0.2rem;
}

.favorite-price-grid strong {
    color: #0f172a;
    font-size: 0.82rem;
}

.favorite-threshold-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.favorite-threshold-row label {
    color: #475569;
    font-weight: 600;
    font-size: 0.8rem;
}

.favorite-threshold-select {
    min-width: 68px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
}

.favorite-actions {
    display: flex;
    justify-content: flex-end;
}

.favorite-detail-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.52rem 0.78rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    color: #fff;
    font-size: 0.8rem;
}

.favorites-confirm-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 2rem));
    background: #fff;
    border-radius: 22px;
    padding: 1.8rem;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
    text-align: center;
}

.favorites-confirm-dialog h3 {
    font-family: 'Poppins', sans-serif;
    color: #0f172a;
    margin-bottom: 0.6rem;
}

.favorites-confirm-dialog p {
    color: #64748b;
}

.favorites-confirm-actions {
    margin-top: 1.4rem;
    display: flex;
    justify-content: center;
    gap: 0.8rem;
}

.favorites-confirm-secondary,
.favorites-confirm-primary {
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.15rem;
    font-weight: 700;
    cursor: pointer;
}

.favorites-confirm-secondary {
    background: #f1f5f9;
    color: #475569;
}

.favorites-confirm-primary {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    color: #fff;
}

@media (max-width: 640px) {
    .favorites-panel-dialog {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }

    .favorites-panel-header {
        padding: 1rem;
    }

    .favorites-panel-header h2 {
        font-size: 1.25rem;
    }

    .favorites-panel-subtitle {
        font-size: 0.88rem;
        line-height: 1.45;
    }

    .favorites-panel-body {
        padding: 0.75rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .favorite-item {
        grid-template-columns: 1fr;
    }

    .favorite-item-media img {
        width: 100%;
        height: min(140px, 34dvh);
    }

    .favorite-price-grid {
        grid-template-columns: 1fr;
    }

    .favorite-threshold-row,
    .favorite-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .favorite-threshold-select,
    .favorite-detail-button {
        width: 100%;
    }
}
