/**
 * Stili Autenticazione - meteo.sm
 * Centro Meteorologico Sammarinese
 */

/* =========================================================================
   CSS Variables
   ========================================================================= */
:root {
    --auth-primary: #0066cc;
    --auth-primary-hover: #0052a3;
    --auth-primary-light: #e6f0fa;
    --auth-success: #28a745;
    --auth-error: #dc3545;
    --auth-warning: #ffc107;
    --auth-text: #333;
    --auth-text-muted: #666;
    --auth-border: #ddd;
    --auth-bg: #fff;
    --auth-overlay: rgba(0, 0, 0, 0.5);
    --auth-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    --auth-radius: 12px;
    --auth-radius-sm: 6px;
    --auth-transition: 0.2s ease;
}

/* Dark mode support - usa data-theme per consistenza con app.css */
[data-theme="dark"] {
    --auth-text: #e0e0e0;
    --auth-text-muted: #999;
    --auth-border: #444;
    --auth-bg: #1a1a2e;
    --auth-overlay: rgba(0, 0, 0, 0.7);
    --auth-primary-light: #1a365d;
}

/* =========================================================================
   Modal Container
   ========================================================================= */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s ease;
}

.auth-modal.active {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s ease;
}

.auth-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--auth-overlay);
    cursor: pointer;
}

.auth-modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    margin: 20px;
    padding: 30px;
    background: var(--auth-bg);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.auth-modal.active .auth-modal-content {
    transform: scale(1);
}

/* Close button */
.auth-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--auth-text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--auth-transition), color var(--auth-transition);
    line-height: 1;
    padding: 0;
}

.auth-modal-close:hover {
    background: var(--auth-primary-light);
    color: var(--auth-primary);
}

/* =========================================================================
   Header
   ========================================================================= */
.auth-modal-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--auth-primary);
}

.auth-logo {
    font-size: 32px;
    font-weight: 700;
    color: var(--auth-primary);
    letter-spacing: -1px;
}

.auth-subtitle {
    font-size: 12px;
    color: var(--auth-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =========================================================================
   Views
   ========================================================================= */
.auth-view {
    display: none;
}

.auth-view.active {
    display: block;
    animation: authFadeIn 0.3s ease;
}

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

.auth-view h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--auth-text);
    margin: 0 0 20px 0;
    text-align: center;
}

.auth-description {
    color: var(--auth-text-muted);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-description.small {
    font-size: 13px;
}

.auth-description strong {
    color: var(--auth-text);
}

/* =========================================================================
   Google Button
   ========================================================================= */
.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-bg);
    color: var(--auth-text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--auth-transition), border-color var(--auth-transition);
}

.auth-google-btn:hover {
    background: var(--auth-primary-light);
    border-color: var(--auth-primary);
}

.auth-google-btn svg {
    flex-shrink: 0;
}

/* =========================================================================
   Divider
   ========================================================================= */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--auth-text-muted);
    font-size: 13px;
}

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

.auth-divider span {
    padding: 0 15px;
}

/* =========================================================================
   Form Fields
   ========================================================================= */
.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--auth-text);
    margin-bottom: 6px;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    font-size: 15px;
    color: var(--auth-text);
    background: var(--auth-bg);
    transition: border-color var(--auth-transition), box-shadow var(--auth-transition);
    box-sizing: border-box;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px var(--auth-primary-light);
}

.auth-field input::placeholder {
    color: var(--auth-text-muted);
}

.auth-field small {
    display: block;
    font-size: 12px;
    color: var(--auth-text-muted);
    margin-top: 4px;
}

/* Password Input with Toggle */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 44px; /* Space for toggle button */
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--auth-text-muted);
    border-radius: 4px;
    transition: color var(--auth-transition), background var(--auth-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--auth-primary);
    background: var(--auth-primary-light);
}

.password-toggle:focus {
    outline: none;
    color: var(--auth-primary);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* Row layouts */
.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.auth-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 480px) {
    .auth-row-2 {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   Checkbox
   ========================================================================= */
.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--auth-text);
}

.auth-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--auth-primary);
    flex-shrink: 0;
}

.auth-checkbox span {
    line-height: 1.4;
}

.auth-checkbox a {
    color: var(--auth-primary);
    text-decoration: none;
}

.auth-checkbox a:hover {
    text-decoration: underline;
}

.auth-consents {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--auth-primary-light);
    border-radius: var(--auth-radius-sm);
}

/* =========================================================================
   Links
   ========================================================================= */
.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 14px;
}

.auth-link:hover {
    text-decoration: underline;
}

/* =========================================================================
   Error Message
   ========================================================================= */
.auth-error {
    color: var(--auth-error);
    font-size: 14px;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: rgba(220, 53, 69, 0.1);
    border-radius: var(--auth-radius-sm);
    display: none;
}

.auth-error:not(:empty) {
    display: block;
}

/* =========================================================================
   Submit Button
   ========================================================================= */
.auth-submit-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--auth-radius-sm);
    background: var(--auth-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--auth-transition), transform var(--auth-transition);
}

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

.auth-submit-btn:active {
    transform: scale(0.98);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =========================================================================
   Footer
   ========================================================================= */
.auth-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
    text-align: center;
    font-size: 14px;
    color: var(--auth-text-muted);
}

.auth-footer a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* =========================================================================
   Success Icon
   ========================================================================= */
.auth-success-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 20px;
    color: var(--auth-success);
}

/* =========================================================================
   Loading Overlay
   ========================================================================= */
.auth-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--auth-radius);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0s 0.2s;
}

.auth-loading.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s;
}

.auth-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--auth-border);
    border-top-color: var(--auth-primary);
    border-radius: 50%;
    animation: authSpin 0.8s linear infinite;
}

@keyframes authSpin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================================
   Toast Notification
   ========================================================================= */
.auth-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    border-radius: var(--auth-radius-sm);
    background: var(--auth-text);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}

.auth-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.auth-toast-success {
    background: var(--auth-success);
}

.auth-toast-error {
    background: var(--auth-error);
}

.auth-toast-warning {
    background: var(--auth-warning);
    color: #333;
}

/* =========================================================================
   Header Auth Elements
   ========================================================================= */
.auth-header-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Login Button */
.auth-login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    border: 1px solid var(--auth-primary);
    border-radius: var(--auth-radius-sm);
    background: transparent;
    color: var(--auth-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--auth-transition), color var(--auth-transition);
}

.auth-login-btn:hover {
    background: var(--auth-primary);
    color: #fff;
}

.auth-login-btn svg {
    width: 18px;
    height: 18px;
}

/* Auth button on blue header - fix contrast */
.app-header .auth-login-btn {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.7);
}
.app-header .auth-login-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: #fff;
}

/* User menu on blue header - fix contrast */
.app-header .auth-user-name {
    color: #fff;
}

.app-header .auth-user-dropdown-btn {
    color: rgba(255, 255, 255, 0.8);
}

.app-header .auth-user-dropdown-btn:hover {
    color: #fff;
}

/* User Menu */
.auth-user-menu {
    display: none;
    align-items: center;
    gap: 8px;
    position: relative;
}

.auth-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: none;
}

.auth-user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--auth-primary-light);
    color: var(--auth-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.auth-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--auth-text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-user-dropdown-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--auth-text-muted);
    transition: color var(--auth-transition);
}

.auth-user-dropdown-btn:hover {
    color: var(--auth-text);
}

/* Dropdown Menu */
.auth-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--auth-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
    z-index: 100;
}

.auth-user-menu.open .auth-user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s, transform 0.2s;
}

.auth-user-dropdown a,
.auth-user-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--auth-text);
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--auth-transition);
    text-align: left;
}

.auth-user-dropdown a:hover,
.auth-user-dropdown button:hover {
    background: var(--auth-primary-light);
}

.auth-user-dropdown hr {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--auth-border);
}

.auth-user-dropdown .logout-btn {
    color: var(--auth-error);
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 480px) {
    .auth-modal-content {
        margin: 10px;
        padding: 20px;
        max-height: 95vh;
    }

    .auth-logo {
        font-size: 26px;
    }

    .auth-view h2 {
        font-size: 20px;
    }

    .auth-user-name {
        display: none;
    }
}

/* =========================================================================
   Cookie Banner (GDPR)
   ========================================================================= */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--auth-bg);
    border-top: 1px solid var(--auth-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cookie-banner.visible {
    transform: translateY(0);
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-banner-text {
    flex: 1;
    min-width: 300px;
    font-size: 14px;
    color: var(--auth-text);
    line-height: 1.5;
}

.cookie-banner-text a {
    color: var(--auth-primary);
}

.cookie-banner-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cookie-banner-btn {
    padding: 10px 20px;
    border-radius: var(--auth-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--auth-transition);
}

.cookie-banner-btn-accept {
    background: var(--auth-primary);
    color: #fff;
    border: none;
}

.cookie-banner-btn-accept:hover {
    background: var(--auth-primary-hover);
}

.cookie-banner-btn-settings {
    background: transparent;
    color: var(--auth-text);
    border: 1px solid var(--auth-border);
}

.cookie-banner-btn-settings:hover {
    background: var(--auth-primary-light);
}

@media (max-width: 600px) {
    .cookie-banner-content {
        flex-direction: column;
        text-align: center;
    }

    .cookie-banner-buttons {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================================================
   Cookie Settings Modal
   ========================================================================= */
.cookie-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s ease;
}

.cookie-settings-modal.active {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s ease;
}

.cookie-settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--auth-overlay);
    cursor: pointer;
}

.cookie-settings-content {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    margin: 20px;
    padding: 30px;
    background: var(--auth-bg);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.cookie-settings-modal.active .cookie-settings-content {
    transform: scale(1);
}

.cookie-settings-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--auth-text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--auth-transition), color var(--auth-transition);
    line-height: 1;
    padding: 0;
}

.cookie-settings-close:hover {
    background: var(--auth-primary-light);
    color: var(--auth-primary);
}

.cookie-settings-content h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--auth-text);
    margin: 0 0 15px 0;
}

.cookie-settings-description {
    color: var(--auth-text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 25px;
}

/* Cookie Category */
.cookie-category {
    padding: 15px;
    margin-bottom: 15px;
    background: var(--auth-primary-light);
    border-radius: var(--auth-radius-sm);
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.cookie-category-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cookie-category-name {
    font-weight: 600;
    color: var(--auth-text);
}

.cookie-category-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--auth-success);
    color: #fff;
    font-weight: 500;
    text-transform: uppercase;
}

.cookie-category-description {
    font-size: 13px;
    color: var(--auth-text-muted);
    margin: 10px 0 0 0;
    line-height: 1.5;
}

/* Cookie Toggle Switch */
.cookie-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

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

.cookie-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--auth-border);
    transition: 0.3s;
    border-radius: 26px;
}

.cookie-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

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

.cookie-toggle.disabled {
    opacity: 0.6;
}

.cookie-toggle.disabled .cookie-toggle-slider {
    cursor: not-allowed;
    background-color: var(--auth-success);
}

/* Cookie Settings Buttons */
.cookie-settings-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.cookie-settings-btn {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border-radius: var(--auth-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--auth-transition), color var(--auth-transition);
}

.cookie-settings-btn-necessary {
    background: transparent;
    border: 1px solid var(--auth-border);
    color: var(--auth-text);
}

.cookie-settings-btn-necessary:hover {
    background: var(--auth-primary-light);
}

.cookie-settings-btn-save {
    background: transparent;
    border: 1px solid var(--auth-primary);
    color: var(--auth-primary);
}

.cookie-settings-btn-save:hover {
    background: var(--auth-primary);
    color: #fff;
}

.cookie-settings-btn-accept {
    background: var(--auth-primary);
    border: none;
    color: #fff;
}

.cookie-settings-btn-accept:hover {
    background: var(--auth-primary-hover);
}

@media (max-width: 480px) {
    .cookie-settings-content {
        margin: 10px;
        padding: 20px;
    }

    .cookie-settings-buttons {
        flex-direction: column;
    }

    .cookie-settings-btn {
        width: 100%;
    }
}

/* =========================================================================
   Access Gating — [data-access] dichiarativo
   Tutti gli elementi sono sempre visibili. Se il tier è insufficiente,
   l'elemento mostra un badge tier e intercetta i click.
   ========================================================================= */

/* -- Tier Palette -- */
:root {
    --tier-user-color: #3b82f6;
    --tier-user-bg: #eff6ff;
    --tier-owner-color: #059669;
    --tier-owner-bg: #ecfdf5;
    --tier-premium-color: #d97706;
    --tier-premium-bg: #fffbeb;
    --tier-editor-color: #7c3aed;
    --tier-editor-bg: #f5f3ff;
    --tier-admin-color: #dc2626;
    --tier-admin-bg: #fef2f2;
}

[data-theme="dark"] {
    --tier-user-bg: #1e3a5f;
    --tier-owner-bg: #064e3b;
    --tier-premium-bg: #451a03;
    --tier-editor-bg: #2e1065;
    --tier-admin-bg: #450a0a;
}

/* Elemento con accesso insufficiente: interattivo ma con indicatore */
[data-access].access-locked {
    position: relative;
    cursor: pointer;
}

/* Badge tier — posizionato in alto a destra */
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    z-index: 5;
    pointer-events: none;
    white-space: nowrap;
    font-family: var(--font-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.tier-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

[data-access].access-locked:hover .tier-badge {
    transform: scale(1.05);
}

/* Pill tier dentro il badge (quando c'e' un label custom) */
.tier-badge__pill {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    padding-left: 4px;
    border-left: 1px solid currentColor;
    margin-left: 2px;
}

/* Quando è sbloccato, nessun badge */
[data-access].access-granted .tier-badge {
    display: none;
}

/* Badge inline (per bottoni, link) */
.tier-badge--inline {
    position: static;
    margin-left: 6px;
    top: auto;
    right: auto;
}

/* -- Colori badge per tier -- */
.tier-badge--user {
    background: var(--tier-user-bg);
    color: var(--tier-user-color);
    border: 1px solid color-mix(in srgb, var(--tier-user-color) 20%, transparent);
}

.tier-badge--owner {
    background: var(--tier-owner-bg);
    color: var(--tier-owner-color);
    border: 1px solid color-mix(in srgb, var(--tier-owner-color) 20%, transparent);
}

.tier-badge--premium {
    background: var(--tier-premium-bg);
    color: var(--tier-premium-color);
    border: 1px solid color-mix(in srgb, var(--tier-premium-color) 20%, transparent);
}

.tier-badge--editor {
    background: var(--tier-editor-bg);
    color: var(--tier-editor-color);
    border: 1px solid color-mix(in srgb, var(--tier-editor-color) 20%, transparent);
}

.tier-badge--admin {
    background: var(--tier-admin-bg);
    color: var(--tier-admin-color);
    border: 1px solid color-mix(in srgb, var(--tier-admin-color) 20%, transparent);
}

/* -- Toast upgrade -- */
.tier-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    background: var(--auth-bg, #fff);
    color: var(--auth-text, #333);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--auth-border, #ddd);
    font-size: 14px;
    line-height: 1.4;
    max-width: 420px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.tier-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.tier-toast__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tier-toast__icon svg {
    width: 18px;
    height: 18px;
}

.tier-toast__icon--user { background: var(--tier-user-bg); color: var(--tier-user-color); }
.tier-toast__icon--owner { background: var(--tier-owner-bg); color: var(--tier-owner-color); }
.tier-toast__icon--premium { background: var(--tier-premium-bg); color: var(--tier-premium-color); }
.tier-toast__icon--editor { background: var(--tier-editor-bg); color: var(--tier-editor-color); }
.tier-toast__icon--admin { background: var(--tier-admin-bg); color: var(--tier-admin-color); }

.tier-toast__body {
    flex: 1;
    min-width: 0;
}

.tier-toast__title {
    font-weight: 600;
    margin-bottom: 2px;
}

.tier-toast__desc {
    font-size: 13px;
    color: var(--auth-text-muted, #666);
}

.tier-toast__action {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s;
}

.tier-toast__action--user { background: var(--tier-user-color); color: #fff; }
.tier-toast__action--owner { background: var(--tier-owner-color); color: #fff; }
.tier-toast__action--premium { background: var(--tier-premium-color); color: #fff; }
.tier-toast__action--editor { background: var(--tier-editor-color); color: #fff; }
.tier-toast__action--admin { background: var(--tier-admin-color); color: #fff; }

.tier-toast__action:hover { filter: brightness(1.1); }

/* -- Sfocatura opzionale (data-access-blur) -- */
[data-access].access-locked[data-access-blur] {
    overflow: hidden;
}

[data-access].access-locked[data-access-blur] > *:not(.tier-badge):not(.access-blur-overlay) {
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
}

.access-blur-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    cursor: pointer;
}

/* -- Responsive -- */
@media (max-width: 480px) {
    .tier-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    .tier-toast {
        bottom: 12px;
        left: 12px;
        right: 12px;
        max-width: none;
        transform: translateX(0) translateY(20px);
    }
    .tier-toast.visible {
        transform: translateX(0) translateY(0);
    }
}

/* =========================================================================
   Page Gate Overlay (page_gate.js)
   ========================================================================= */

#page-gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] #page-gate-overlay {
    background: rgba(26, 26, 46, 0.97);
}

.page-gate-card {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.page-gate-icon {
    margin-bottom: 20px;
    color: var(--auth-primary, #0066cc);
}

.page-gate-card h2 {
    margin: 0 0 12px 0;
    color: var(--auth-text, #333);
    font-size: 22px;
    font-weight: 600;
}

.page-gate-card p {
    margin: 0 0 24px 0;
    color: var(--auth-text-muted, #666);
    font-size: 14px;
    line-height: 1.5;
}

.page-gate-btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    margin: 0 6px;
}

.page-gate-btn:active {
    transform: scale(0.98);
}

.page-gate-btn-primary {
    background: var(--auth-primary, #0066cc);
    color: #fff;
}

.page-gate-btn-primary:hover {
    background: var(--auth-primary-hover, #0052a3);
}

.page-gate-btn-secondary {
    background: transparent;
    color: var(--auth-text-muted, #666);
    padding: 12px 16px;
}

.page-gate-btn-secondary:hover {
    text-decoration: underline;
}

.page-gate-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--auth-border, #ddd);
    border-top-color: var(--auth-primary, #0066cc);
    border-radius: 50%;
    animation: authSpin 0.8s linear infinite;
    margin-bottom: 16px;
}

.page-gate-loading-text {
    color: var(--auth-text-muted, #666);
    font-size: 14px;
}
