/**
 * 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%;
    }
}
