:root {
    --bg-dark: #0a0a0c;
    --bg-card: rgba(255, 255, 255, 0.03);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #64748b;
    --accent: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    color-scheme: dark;

    /* Compatibility variables for other sections */
    --surface-color: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius: 12px;
    --text-color: #f8fafc;
    --background-color: #0a0a0c;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: linear-gradient(135deg, #fff 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: color 0.3s ease;
}

.btn-ghost:hover {
    color: white;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Glassmorphism */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

/* Header */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1.25rem 0;
    background: rgba(10, 10, 12, 0.75);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

.glass-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Header Navigation */
#top-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lang-selector {
    display: flex;
    align-items: center;
}

.lang-select {
    padding: 0.35rem 1.75rem 0.35rem 0.75rem !important;
    font-size: 0.75rem !important;
    font-weight: 600;
    border-radius: 6px !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    width: auto !important;
    height: auto !important;
    cursor: pointer;
    color: var(--text-main) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-position: right 0.5rem center !important;
}

.lang-select:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.logo-icon {
    color: var(--primary);
    display: flex;
}

/* Hero Section */
.hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
    padding: 8rem 0;
}

.hero h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.hero-actions {
    display: flex;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .hero-actions {
        flex-direction: column;
        gap: 1rem;
    }
    .hero-actions button {
        width: 100%;
    }
}

/* Preview Card Animation */
.preview-card {
    height: 400px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    position: relative;
    overflow: hidden;
}

.card-header {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.red { background: #ff5f56; }
.yellow { background: #ffbd2e; }
.green { background: #27c93f; }

.skeleton-line {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    width: 100%;
}

.skeleton-line.title {
    height: 24px;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-line.short {
    width: 40%;
}

/* Flow Layout */
.flow-layout {
    display: grid;
    grid-template-columns: 250px 1fr 350px;
    gap: 2rem;
    margin-top: 2rem;
    animation: fadeIn 0.5s ease;
}

@media (max-width: 1024px) {
    .flow-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .sidebar, .preview-sidebar {
        display: none; /* Nascondi barre laterali su mobile per dare spazio al form */
    }
    .preview-sidebar.active {
        display: block; /* Mostra anteprima solo se richiesto */
    }
}

.sidebar, .preview-sidebar {
    position: relative;
}

.preview-sticky {
    position: sticky;
    top: 100px;
}

/* Steps Progress */
.steps-progress {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.step-item.active {
    background: var(--glass-bg);
    color: var(--primary);
}

.step-item.completed {
    color: #10b981;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Form Styles */
.flow-card {
    padding: 2.5rem;
    min-height: 400px;
}

@media (max-width: 600px) {
    .flow-card {
        padding: 1.25rem;
        min-height: auto;
    }
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input, select, textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    color: white;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

option {
    background-color: #1a1a1e; /* Solid color for better browser support */
    color: white;
}

/* Chrome/Windows specific fix for dropdown contrast */
select option {
    background-color: #1a1a1e;
    color: white;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 600px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
}

.template-option {
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.template-option:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.template-option.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.template-option i {
    width: 40px;
    height: 40px;
}

.template-option-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 5;
}

.favorite-btn, .visibility-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.favorite-btn:hover, .visibility-btn:hover {
    color: white;
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

.favorite-active {
    color: #f59e0b !important;
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.1) !important;
}

.hidden-active {
    color: #ef4444 !important;
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

.template-hidden {
    opacity: 0.5;
    border-style: dashed !important;
}

.template-hidden::after {
    content: 'NASCOSTO';
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: #ef4444;
    letter-spacing: 0.05em;
}

.section-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-subtitle::before {
    content: '';
    display: block;
    width: 4px;
    height: 1.2em;
    background: var(--primary);
    border-radius: 2px;
}

.template-option.extra {
    border-color: rgba(245, 158, 11, 0.2);
}

.template-option.extra:hover {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.05);
}

.template-option.extra.selected {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.template-option.extra i {
    color: var(--accent);
}

/* Selection Layout */
.selection-layout {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.selection-section {
    display: flex;
    flex-direction: column;
}

@media (max-width: 900px) {
    .selection-layout {
        gap: 2rem;
    }
}

.column-main, .column-extra {
    display: flex;
    flex-direction: column;
}

/* Search Bar */
.search-container {
    margin-bottom: 2rem;
    position: relative;
    max-width: 600px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.search-bar {
    padding-left: 3.5rem !important;
    height: 54px;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.search-bar:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 20px var(--primary-glow);
}

@media (max-width: 600px) {
    .search-bar {
        height: 48px;
        font-size: 1rem;
    }
}

.empty-search-msg {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* ── Template Tabs ── */
.template-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    width: fit-content;
}

.template-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.template-tab-btn i { width: 16px; height: 16px; flex-shrink: 0; }

.template-tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 14px var(--primary-glow);
}

.template-tab-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
}

.tab-count {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
}

.template-tab-btn.active .tab-count {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Compact Card Grid ── */
.template-compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.875rem;
    animation: fadeIn 0.25s ease;
}

.template-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
    min-height: 70px;
}

.template-card:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.template-card.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
}

.template-card.extra:hover {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.06);
}

.template-card.extra.selected {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
}

.template-card-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.template-card.extra .template-card-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.template-card-icon i { width: 18px; height: 18px; }

.template-card-body { flex: 1; min-width: 0; }

.template-card-body h4 {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-body p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card.suggest-card {
    border-style: dashed;
    background: transparent;
    opacity: 0.7;
}

.template-card.suggest-card:hover {
    opacity: 1;
    border-color: var(--primary);
}

.template-card.suggest-card .template-card-icon {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.template-card .template-option-actions {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    display: flex;
    gap: 0.25rem;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s;
}

.template-card:hover .template-option-actions { opacity: 1; }

.template-card .template-option-actions .favorite-btn,
.template-card .template-option-actions .visibility-btn {
    width: 24px;
    height: 24px;
}

.template-card .favorite-active ~ .template-option-actions,
.template-card:has(.favorite-active) .template-option-actions { opacity: 1; }

@media (max-width: 600px) {
    .template-compact-grid { 
        grid-template-columns: 1fr; /* Una sola colonna su telefoni piccoli */
    }
    .template-tabs { 
        width: 100%; 
        overflow-x: auto;
        justify-content: flex-start;
    }
    .template-tab-btn { 
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 420px) {
    .template-compact-grid { grid-template-columns: 1fr; }
}


/* Suggest Banner */
.suggest-banner {
    grid-column: 1 / -1;
    margin-top: 3rem;
    padding: 2rem;
    border: 1px dashed var(--glass-border);
    border-radius: var(--radius-lg);
    text-align: left;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.suggest-banner:hover {
    border-color: var(--primary);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%);
    transform: translateY(-5px);
}

.suggest-banner i {
    color: var(--primary);
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.suggest-banner h4 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.suggest-banner p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Document Preview */
.document-preview {
    padding: 1.5rem;
    font-size: 0.85rem;
    min-height: 450px;
    color: #cbd5e1;
    overflow-y: auto;
    max-height: 60vh;
}

.empty-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

/* Footer */
.footer {
    padding: 4rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Utils */
.hidden { display: none; }

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

.form-section-divider {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.05em;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* iOS Style Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.toggle-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-content {
    animation: fadeIn 0.3s ease;
}

.glass-inner {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

/* Dynamic List Styles */
.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.dynamic-row {
    display: grid;
    grid-template-columns: 1fr 120px 50px;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
}

.btn-icon.danger:hover {
    color: #ef4444;
    border-color: #ef4444;
}

/* Option Toggle */
.option-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.btn-toggle {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-toggle.active {
    background: var(--primary);
    color: white;
}

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

.checkbox-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.checkbox-row label:first-child {
    width: auto;
    margin-right: 0.5rem;
}

.checkbox-group.compact {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
}

/* Tooltip */
.info-tooltip-trigger {
    display: inline-flex;
    margin-left: 0.5rem;
    color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}

.info-tooltip-trigger i {
    width: 14px;
    height: 14px;
}

.elegant-tooltip {
    position: fixed;
    z-index: 1000;
    width: 250px;
    background: #1e293b;
    border: 1px solid var(--primary);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.4;
    animation: tooltipIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive */
@media (max-width: 1200px) {
    .flow-layout {
        grid-template-columns: 200px 1fr 300px;
    }
}

@media (max-width: 1024px) {
    .flow-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .sidebar {
        order: -1;
    }
    .preview-sidebar {
        display: block;
        position: relative;
    }
    .preview-sticky {
        position: static;
    }
    .document-preview {
        max-height: 400px;
    }
    .dashboard-premium {
        max-width: 95vw !important;
    }
}

@media (max-width: 768px) {
    .hero {
        grid-template-columns: 1fr;
        padding: 3rem 0 2rem;
        text-align: center;
    }
    .hero h1 { font-size: 2.2rem; }
    .hero-visual { display: none; }
    .hero-actions { justify-content: center; }
    
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-cards-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    #auth-register-view .template-grid,
    .address-fields-grid,
    .billing-options-grid {
        grid-template-columns: 1fr !important;
    }
    .address-fields-grid .span-2 {
        grid-column: span 1;
    }
    .auth-modal {
        max-width: 95vw !important;
    }
    #auth-login-view, #auth-register-view {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 1.9rem; }
    .flow-card {
        padding: 1rem;
    }
    .modal-content {
        padding: 1.25rem;
        width: 100%;
    }
    .logo-text {
        font-size: 1.1rem;
    }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-dark);
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
    position: relative;
    transform: translateY(0);
    transition: transform 0.3s ease;
    z-index: 1001; /* Ensure content is above background */
    pointer-events: auto;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
    pointer-events: none;
}

.modal-content.dashboard-content {
    max-width: 800px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.75rem;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1010;
}

/* Quando il close-btn è dentro .auth-tabs (auth modal) */
.auth-tabs .close-btn {
    margin-left: auto;
    margin-right: 0.75rem;
    position: relative;
    top: auto;
    right: auto;
}

/* Quando il close-btn è fuori dai tab (dashboard modal) */
.modal-content > .close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    margin: 0;
}

.close-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions button {
    flex: 1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Premium Auth Modal */
.auth-modal {
    max-width: 700px !important;
    padding: 0 !important;
    overflow: hidden;
    overflow-y: auto;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.auth-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
    align-items: center;
}

.auth-tab {
    flex: 1;
    padding: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.auth-tab.active {
    color: var(--primary);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

#auth-login-view, #auth-register-view {
    padding: 2rem 2.5rem 2.5rem;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    flex: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.input-with-icon input {
    padding-left: 3rem !important;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    padding: 0 1rem;
}

.social-auth {
    display: flex;
    gap: 1rem;
}

.btn-block {
    width: 100%;
}

/* Premium Dashboard */
.dashboard-premium {
    max-width: 1000px !important;
    padding: 2rem !important;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.user-welcome {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-avatar {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
}

.stats-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-premium-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.stat-premium-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-title {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dashboard-section-premium h3 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.recent-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.recent-main {
    display: flex;
    flex-direction: column;
}

.recent-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.recent-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.premium-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-mini {
    position: relative;
    margin-bottom: 1rem;
}

.search-mini i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.search-mini input {
    padding: 0.5rem 0.5rem 0.5rem 2.25rem !important;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.3) !important;
}

.contacts-list-scroll {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-premium-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-premium-item:hover {
    border-color: var(--primary);
}

.contact-info-mini {
    display: flex;
    flex-direction: column;
}

.contact-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.contact-details {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2rem 0;
}


/* Favorites */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-option {
    position: relative;
}

.favorite-active {
    color: #fbbf24;
}
.favorite-active i {
    fill: #fbbf24;
}

.favorite-inactive {
    color: var(--border);
}

.template-option:hover .favorite-inactive {
    color: var(--text-muted);
}

.favorite-inactive:hover {
    color: #fbbf24 !important;
}

/* Form error messages */
.form-error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

.required-star {
    color: #ef4444;
    font-weight: 700;
    margin-left: 2px;
}

.required-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

#auth-register-view .template-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Address autocomplete styles */
.address-autocomplete-wrapper {
    position: relative;
}

.address-autocomplete-wrapper .pac-container {
    border-radius: var(--radius-md);
    border: 1px solid var(--primary);
    background: #1a1a2e;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    font-family: 'Outfit', sans-serif;
    margin-top: 4px;
    z-index: 9999;
}

.pac-item {
    padding: 0.6rem 1rem;
    color: var(--text-main);
    border-top: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.85rem;
}

.pac-item:hover, .pac-item-selected {
    background: rgba(59, 130, 246, 0.1);
}

.pac-item-query {
    color: var(--primary);
    font-size: 0.9rem;
}

.pac-matched {
    font-weight: 700;
}

.address-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.address-fields-grid .form-group {
    margin-bottom: 0;
}

.address-fields-grid .span-2 {
    grid-column: span 2;
}

.address-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.badge-online {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border);
}


/* Select Field Styles */
select {
    width: 100%;
    padding: 0.875rem 1rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select option {
    background-color: #1a1a1e;
    color: white;
}

/* Billing Cards Styles */
.billing-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.billing-card, .payment-method-card {
    cursor: pointer;
    display: block;
}

.billing-card input[type="radio"], .payment-method-card input[type="radio"] {
    display: none;
}

.billing-card-content, .payment-method-content {
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    transition: var(--transition);
    height: 100%;
}

.billing-card input[type="radio"]:checked + .billing-card-content,
.payment-method-card input[type="radio"]:checked + .payment-method-content {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.billing-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.billing-title {
    font-weight: 600;
    color: var(--text-color);
}

.billing-price {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.billing-period {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.payment-methods-row {
    display: flex;
    gap: 1rem;
}

.payment-method-card {
    flex: 1;
}

.payment-method-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    font-weight: 500;
}


/* File Upload Styles */
.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}
.file-input {
    display: none;
}
.file-upload-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    color: var(--text-color);
}
.file-upload-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}
.file-name-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ════════════════════════════════════════════════════
   ADMIN PANEL — TABS
   ════════════════════════════════════════════════════ */
.admin-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0;
}

.admin-panel-tabs {
    display: flex;
    gap: 0.35rem;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-md);
    padding: 0.3rem;
}

.admin-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.admin-tab-btn.active {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    box-shadow: 0 0 18px rgba(59,130,246,0.4);
}

.admin-tab-btn:not(.active):hover {
    background: rgba(255,255,255,0.07);
    color: var(--text-main);
}

/* ════════════════════════════════════════════════════
   REPORT PANEL — LAYOUT
   ════════════════════════════════════════════════════ */
.report-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.report-card {
    padding: 1.5rem;
    border-radius: var(--radius-md);
}

.report-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .report-two-col { grid-template-columns: 1fr; }
}

.report-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9rem;
}

.report-empty-state i {
    width: 40px;
    height: 40px;
    opacity: 0.4;
}

/* ════════════════════════════════════════════════════
   KPI CARDS
   ════════════════════════════════════════════════════ */
.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.report-kpi-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.report-kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.report-kpi-card:hover {
    border-color: rgba(59,130,246,0.25);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.report-kpi-card:hover::before { opacity: 1; }

.kpi-icon-wrap {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon-wrap i { width: 22px; height: 22px; }

.kpi-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-main);
    letter-spacing: -0.03em;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-sub {
    font-size: 0.74rem;
    color: #10b981;
    font-weight: 600;
}

.kpi-trend { font-size: 0.72rem; font-weight: 600; margin-top: 0.1rem; }
.kpi-trend.positive { color: #10b981; }
.kpi-trend.negative { color: #ef4444; }

/* ════════════════════════════════════════════════════
   DONUT CHART
   ════════════════════════════════════════════════════ */
.report-donut-layout {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.donut-wrapper {
    position: relative;
    flex-shrink: 0;
}

.donut-center-label {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-total {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-main);
}

.donut-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-width: 140px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label { flex: 1; color: var(--text-muted); }
.legend-count { font-weight: 700; color: var(--text-main); }
.legend-pct { font-weight: 400; color: var(--text-muted); font-size: 0.75rem; }

/* ════════════════════════════════════════════════════
   NATIONALITY BARS
   ════════════════════════════════════════════════════ */
.nationality-bars-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.nationality-bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 65px;
    align-items: center;
    gap: 0.65rem;
}

.nationality-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.nat-flag { font-size: 1.05rem; flex-shrink: 0; }

.nat-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nationality-bar-track {
    background: rgba(255,255,255,0.06);
    border-radius: 100px;
    height: 7px;
    overflow: hidden;
}

.nationality-bar-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nationality-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
}

.nat-count { font-size: 0.8rem; font-weight: 700; color: var(--text-main); line-height: 1; }
.nat-pct   { font-size: 0.68rem; color: var(--text-muted); }

/* ════════════════════════════════════════════════════
   RANKING TABLE
   ════════════════════════════════════════════════════ */
.report-rank-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.report-rank-table thead th {
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.report-rank-table tbody .rank-row {
    transition: background 0.15s;
}

.report-rank-table tbody .rank-row:hover {
    background: rgba(255,255,255,0.03);
}

.report-rank-table tbody .rank-row td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

.rank-row.rank-gold td {
    background: rgba(245,158,11,0.04);
}

.rank-pos { font-size: 1.1rem; width: 40px; }

.rank-name {
    font-weight: 500;
    color: var(--text-main);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-revenue { font-weight: 700; color: #10b981; font-size: 0.82rem; }

.download-badge {
    display: inline-block;
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 20px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
}

/* ════════════════════════════════════════════════════
   RECENT USERS LIST
   ════════════════════════════════════════════════════ */
.recent-user-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.recent-user-row:last-child { border-bottom: none; }

.recent-user-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
}

.recent-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.recent-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-user-email {
    font-size: 0.73rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.recent-user-plan {
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
    white-space: nowrap;
}

.recent-user-date {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ════════════════════════════════════════════════════
   ADMIN TEMPLATES BADGES
   ════════════════════════════════════════════════════ */
.badge-visible, .badge-hidden {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-visible {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-hidden {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --- Beta Styles --- */
.beta-banner {
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    position: relative;
    z-index: 101;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.beta-banner .container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.badge-beta {
    background: white;
    color: #3b82f6;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.price-old {
    text-decoration: line-through;
    opacity: 0.5;
    font-size: 0.8em;
    margin-right: 0.5rem;
}

.price-free {
    color: #10b981;
    font-weight: 800;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.social-auth {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.social-auth .btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.6rem;
}


/* ═══════════════════════════════════════════════════════════
   PWA INSTALL BUTTON
   ═══════════════════════════════════════════════════════════ */
.btn-install-pwa {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 14px rgba(16,185,129,0.4);
    white-space: nowrap;
    animation: pulse-green 2s infinite;
}

.btn-install-pwa i {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn-install-pwa:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 22px rgba(16,185,129,0.6);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 14px rgba(16,185,129,0.4); }
    50%       { box-shadow: 0 0 24px rgba(16,185,129,0.7); }
}

/* Su schermi molto piccoli nascondi la label, tieni solo l'icona */
@media (max-width: 420px) {
    .install-btn-label { display: none; }
    .btn-install-pwa { padding: 0.5rem; border-radius: 50%; }
}

/* ═══════════════════════════════════════════════════════════
   iOS INSTALL MODAL STEPS
   ═══════════════════════════════════════════════════════════ */
.ios-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.5;
}

.ios-step-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — FIX 2
   Ottimizzazione completa per smartphone (≤768px)
   ═══════════════════════════════════════════════════════════ */

/* --- Header su mobile --- */
@media (max-width: 768px) {
    .glass-header .container {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    #top-nav {
        gap: 0.25rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    /* Nascondi il testo "Aiuto" e "Area Personale" su mobile piccolo, 
       mantieni solo le icone / testo breve */
    #btn-nav-login,
    #btn-nav-dashboard {
        font-size: 0.8rem;
        padding: 0.4rem 0.65rem;
    }

    .lang-select {
        padding: 0.3rem 1.5rem 0.3rem 0.5rem !important;
        font-size: 0.7rem !important;
    }
}

/* --- Hero su mobile --- */
@media (max-width: 768px) {
    .hero {
        grid-template-columns: 1fr;
        padding: 3rem 0 2rem;
        gap: 2rem;
        text-align: center;
    }

    .hero h1 {
        font-size: 2.2rem;
        line-height: 1.2;
    }

    .hero p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .hero-visual {
        display: none; /* Nasconde la preview card decorativa su mobile */
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-actions button {
        width: 100%;
        max-width: 320px;
    }
}

/* --- Flow / Form su mobile --- */
@media (max-width: 768px) {
    .flow-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
    }

    .sidebar,
    .preview-sidebar {
        display: none !important;
    }

    .flow-card {
        padding: 1rem;
        min-height: auto;
    }

    .form-actions {
        display: flex;
        gap: 0.75rem;
        padding: 0.75rem 0;
    }

    .form-actions button {
        flex: 1;
    }
}

/* --- Template grid su mobile --- */
@media (max-width: 768px) {
    .form-container {
        min-width: 0;
        width: 100%;
        overflow: hidden;
    }

    .template-compact-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .template-tabs {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.35rem;
        padding-bottom: 0.25rem;
    }

    .template-tab-btn {
        font-size: 0.78rem;
        padding: 0.45rem 0.75rem;
        flex: 1;
        justify-content: center;
        text-align: center;
        white-space: normal;
    }

    .tab-count {
        font-size: 0.65rem;
        padding: 0.05rem 0.35rem;
    }
}

/* --- Modal generica su mobile --- */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
        align-items: flex-end; /* Sheet dal basso su mobile */
    }

    .modal-content {
        max-width: 100% !important;
        width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92dvh;
        overflow-y: auto;
    }
}

/* --- Auth modal (Login/Registrazione) su mobile --- */
@media (max-width: 768px) {
    .auth-modal {
        padding: 1.25rem;
    }

    .auth-tabs {
        gap: 0.35rem;
        margin-bottom: 1rem;
    }

    .auth-tab {
        font-size: 0.85rem;
        padding: 0.45rem 0.85rem;
    }

    /* Campi in colonna singola su mobile nella registrazione */
    #auth-register-view .template-grid {
        grid-template-columns: 1fr !important;
    }

    .address-fields-grid {
        grid-template-columns: 1fr 1fr;
    }

    .address-fields-grid .span-2 {
        grid-column: span 2;
    }

    .billing-options-grid {
        grid-template-columns: 1fr;
    }

    .payment-methods-row {
        flex-direction: column;
    }
}

/* --- Dashboard utente su mobile --- */
@media (max-width: 768px) {
    .dashboard-premium {
        padding: 1.25rem;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .dashboard-main-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .stats-cards-row {
        grid-template-columns: 1fr 1fr;
    }

    .stat-premium-card {
        padding: 0.85rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* --- Admin Panel su mobile --- */
@media (max-width: 768px) {
    .admin-tabs-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .admin-panel-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        gap: 0.25rem;
    }

    .admin-tab-btn {
        font-size: 0.78rem;
        padding: 0.45rem 0.75rem;
        white-space: nowrap;
    }

    #admin-users-header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    #admin-users-header-actions .search-mini {
        max-width: 100% !important;
    }

    /* Tabella admin: scroll orizzontale su mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table {
        min-width: 560px;
    }

    /* KPI grid in 2 colonne su mobile */
    .report-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Report a colonna singola */
    .report-two-col {
        grid-template-columns: 1fr;
    }
}

/* --- Dashboard header avatar piccolo su mobile --- */
@media (max-width: 480px) {
    .user-avatar {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .dashboard-header h2 {
        font-size: 1.1rem;
    }

    /* KPI singola colonna su telefoni piccoli */
    .report-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* Assicura che il beta banner sia leggibile su mobile */
@media (max-width: 480px) {
    .beta-banner {
        font-size: 0.72rem;
        padding: 0.4rem 0;
    }

    .beta-banner .container {
        gap: 0.4rem;
        padding: 0 0.75rem;
    }
}
