/* Header */
.header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    padding: 0 2rem 0 6rem;
    /* Adjusted left padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 2.75rem;
}

.header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.header h1 .icon {
    display: none;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
    /* Push to right */
}

.admin-link {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570, #ea4335);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: opacity 0.3s;
    margin-right: 1rem;
}

.admin-link:hover {
    opacity: 0.7;
    text-decoration: none;
}

/* Corner Fold (Left Side) */
.corner-fold {
    position: fixed;
    top: 0;
    left: 0;
    width: 150px;
    height: 150px;
    z-index: 1001;
    cursor: pointer;
}

/* Ombra morbida sulla pagina sottostante */
.corner-fold::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0.15) 100%);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* La piega della pagina (il retro del foglio) */
.corner-fold::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    /* Flipped gradient for left fold */
    background: radial-gradient(circle at 0% 0%, #ffffff 0%, #f0f0f0 70%, #dcdcdc 100%);
    box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    border-bottom-right-radius: 8px;
    /* Changed to right */
    filter: none;
}

/* Lo sfondo colorato scoperto (Google AI Style) */
.corner-fold-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    background: linear-gradient(135deg,
            rgba(66, 133, 244, 0.8),
            rgba(155, 114, 203, 0.8),
            rgba(217, 101, 112, 0.8),
            rgba(234, 67, 53, 0.8),
            rgba(251, 188, 5, 0.8),
            rgba(52, 168, 83, 0.8));
    background-size: 300% 300%;
    border-right: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

@keyframes google-ai-dynamic {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Stato iniziale visibile (piccola orecchia) */
.corner-fold::before,
.corner-fold::after,
.corner-fold-bg {
    width: 40px;
    height: 40px;
}

.corner-fold::after {
    /* Flipped clip-path for left fold */
    clip-path: polygon(-10% 110%, 110% -10%, 110% 110%);
}

.corner-fold-bg {
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* Hover: sfoglia la pagina */
.corner-fold:hover::before {
    width: 125px;
    height: 125px;
    filter: blur(10px);
    /* Increased blur for softer shadow */
}

.corner-fold:hover::after {
    width: 125px;
    height: 125px;
    box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.2);
    filter: url(#paper-wrinkle);
}

.corner-fold:hover .corner-fold-bg {
    width: 125px;
    height: 125px;
    animation: google-ai-dynamic 6s ease-in-out;
}

.corner-fold-text {
    position: absolute;
    top: 25px;
    left: 15px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    transform: rotate(-45deg);
    pointer-events: none;
    opacity: 0;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.4s ease;
    z-index: 3;
}

.corner-fold:hover .corner-fold-text {
    opacity: 1;
    top: 45px;
    left: 25px;
}

/* Nascondi il vecchio bottone se presente nel JS */
#btnScrape {
    display: none !important;
}

/* Buttons */
.btn {
    padding: 0 16px;
    height: 32px;
    border-radius: var(--radius-xs);
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    white-space: nowrap;
}

.btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.02);
}

.btn-primary {
    background: var(--blue);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.btn-primary:hover {
    background: #0066d6;
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.3);
    transform: translateY(-1px);
}

.btn-ai {
    background: #ffffff !important;
    color: var(--text) !important;
    border: none !important;
    background-clip: padding-box !important;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

/* Google AI Style Shimmering Border */
.btn-ai::before {
    content: "";
    position: absolute;
    inset: -1.5px;
    padding: 1.5px;
    border-radius: 11.5px;
    background: linear-gradient(90deg,
            #4285f4, #9b72cb, #d96570, #ea4335, #fbbc05, #34a853, #4285f4);
    background-size: 200% auto;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
}

.btn-ai:hover::before {
    animation: ai-border-shimmer 4s linear infinite;
}

@keyframes ai-border-shimmer {
    to {
        background-position: 200% center;
    }
}

.btn-ai::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    border-radius: inherit;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), transparent);
    pointer-events: none;
}

.btn-ai:hover {
    transform: scale(1.02) translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

/* Low Power Mode Overrides */
body.low-graphics *,
body.adaptive-low-graphics * {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}

body.low-graphics .btn-ai::before,
body.adaptive-low-graphics .btn-ai::before {
    background: #d2d2d7 !important;
    animation: none !important;
    mask: none !important;
    -webkit-mask: none !important;
    border: 1px solid #d2d2d7;
    inset: 0;
    padding: 0;
}

body.low-graphics .modal,
body.low-graphics .modal-content,
body.low-graphics .status-bar,
body.adaptive-low-graphics .modal,
body.adaptive-low-graphics .modal-content,
body.adaptive-low-graphics .status-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-danger {
    color: var(--red);
    background: var(--red-bg);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.12);
}

.btn-sm {
    padding: 0 12px;
    height: 28px;
    font-size: 12px;
}

.main {
    padding: 1rem 2rem;
    max-width: 87.5rem;
    margin: 0 auto;
}

/* Global Footer Styles & Dock Effect */
.footer-note {
    font-size: 12px;
    color: var(--text3, #9ca3af);
    font-weight: 500;
    text-align: center;
    padding: 6px 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.08);
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 0.75rem;
}

.footer-meta {
    pointer-events: auto;
    grid-column: 2;
    justify-self: center;
    text-align: center;
}

.footer-active-users {
    grid-column: 3;
    justify-self: end;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text2);
    font-size: 11px;
    font-weight: 600;
    height: 24px;
    padding: 0 8px;
    cursor: pointer;
    transition: all var(--transition);
    position: static;
    transform: none;
    margin: 0;
}

.footer-active-users:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(66, 133, 244, 0.4);
    color: var(--blue);
}

.footer-absolute {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    padding-bottom: 0;
    z-index: 1000;
}

@keyframes textShimmer {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.dock-link {
    display: inline-flex;
    align-items: baseline;
    position: relative;
    padding: 0 4px;
    white-space: nowrap;
}

.dock-char {
    display: inline-block;
    transition: transform 0.1s cubic-bezier(0.2, 0, 0, 1);
    transform-origin: bottom center;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(90deg, #4285f4, #ea4335, #fbbc05, #34a853, #4285f4);
    background-size: 200vw auto;
    background-attachment: fixed;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    padding: 0 0.5px;
}

.dock-link:hover .dock-char {
    animation: textShimmer 3s linear infinite;
}

/* --- GLOBAL LOADING SPINNER --- */
/* Moved from controls.css to be available on all pages (login, admin, etc.) */

/* Loading Overlay & Futuristic Spinner */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay .zf-ring,
.loading-overlay .zf-ring-2,
.loading-overlay .zf-ring-3 {
    animation-play-state: paused;
}

.loading-overlay.active .zf-ring,
.loading-overlay.active .zf-ring-2,
.loading-overlay.active .zf-ring-3 {
    animation-play-state: running;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transform: translateY(20px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.loading-overlay.active .spinner-container {
    transform: translateY(0);
}

/* ZF Golden Spiral (Fractal Vortex) */
.zf-spiral-loader {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.zf-text {
    font-size: 16px;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: #000000;
    /* Solid Black, High Visibility */
    z-index: 20;
    position: relative;
    letter-spacing: -0.5px;
}

/* Base ring style for fractal spiral arms */
.zf-ring,
.zf-ring-2,
.zf-ring-3 {
    position: absolute;
    border-radius: 50%;
    /* Create a fading spiral tail */
    background: conic-gradient(from 0deg, transparent 0%, transparent 20%, currentColor 100%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    animation: spiral-spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    mix-blend-mode: multiply;
}

/* Layer 1: Outer Arm (Blue) - Base Scale */
.zf-ring {
    inset: 0;
    color: #4285f4;
    animation-delay: -0.1s;
}

/* Layer 2: Middle Arm (Red) - Scaled Down (Fractal Step) */
.zf-ring-2 {
    inset: 0;
    width: 80%;
    /* Increased from 72% to move away from center */
    height: 80%;
    margin: auto;
    color: #ea4335;
    animation-delay: -0.2s;
    /* Golden Angle Offset approx */
    transform: rotate(137.5deg);
}

/* Layer 3: Inner Arm (Yellow) - Scaled Down Further */
.zf-ring-3 {
    inset: 0;
    width: 55%;
    /* Increased from 45% to move away from center */
    height: 55%;
    margin: auto;
    color: #fbbc05;
    animation-delay: -0.3s;
    /* 2x Golden Angle */
    transform: rotate(275deg);
}



@keyframes spiral-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Override transform for specific rings to maintain relative offset while spinning */
/* We need to apply the rotation offset ON TOP of the animation. 
   Best way is to wrap or use a wrapper, but with 3 divs restricted, we use different animations or `from/to` with offsets.
*/

.zf-ring {
    animation-name: spin-0;
}

.zf-ring-2 {
    animation-name: spin-137;
}

.zf-ring-3 {
    animation-name: spin-275;
}

@keyframes spin-0 {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spin-137 {
    from {
        transform: rotate(137.5deg);
    }

    to {
        transform: rotate(497.5deg);
    }
}

@keyframes spin-275 {
    from {
        transform: rotate(275deg);
    }

    to {
        transform: rotate(635deg);
    }
}

.loading-text {
    font-size: 13px;
    font-weight: 500;
    /* More sober weight */
    color: #5f6368;
    /* Dark Grey (Sober) instead of stark black */
    font-family: 'Inter', sans-serif;
    /* Sober standard font */
    letter-spacing: 0.5px;
    margin-top: 16px;
    /* Slightly more breathing room */
}
