/* ============================================================
   TAMUDATA (TD) Premium Branded Loader System
   ============================================================ */

:root {
    --td-primary: #0A1F44;
    --td-primary-light: #1a4f8b;
    --td-accent: #2e86de;
    --td-cyan: #06d6f2;
    --td-success: #10b981;
    --td-error: #ef4444;
    --td-text: #0c203d;
    --td-text-sub: #6b7f99;
    --td-overlay: rgba(5, 12, 30, 0.72);
    --td-glass: rgba(255, 255, 255, 0.97);
    --td-glow: rgba(46, 134, 222, 0.35);
    --td-neon: 0 0 30px rgba(6, 214, 242, 0.25), 0 0 60px rgba(46, 134, 222, 0.12);
}

/* ---- Overlay ---- */
.td-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--td-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(.4, 0, .2, 1);
    font-family: 'Poppins', sans-serif;
}

.td-loader-overlay.td-visible {
    display: flex;
    pointer-events: all;
}

.td-loader-overlay.td-fade-in {
    opacity: 1;
}

/* Block all interaction behind loader */
.td-loader-overlay.td-visible ~ * {
    pointer-events: none !important;
}

body.td-loading {
    overflow: hidden;
}

/* ---- Glass Card ---- */
.td-loader-card {
    width: min(88vw, 340px);
    background: var(--td-glass);
    border-radius: 24px;
    padding: 40px 32px 36px;
    text-align: center;
    box-shadow:
        0 24px 64px rgba(5, 12, 30, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        var(--td-neon);
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(.34, 1.56, .64, 1),
                opacity 0.35s ease;
    position: relative;
}

.td-loader-overlay.td-fade-in .td-loader-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ---- Logo Container with Spinning Ring ---- */
.td-logo-wrap {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 0 auto 24px;
}

/* Rotating gradient ring */
.td-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 4px;
    background: conic-gradient(
        from 0deg,
        var(--td-cyan),
        var(--td-accent),
        var(--td-primary),
        transparent 70%
    );
    -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: td-ring-spin 1.8s linear infinite;
}

/* Inner logo circle */
.td-logo-inner {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffffff 0%, #e8f0fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 8px rgba(10, 31, 68, 0.06);
    animation: td-pulse 2.5s ease-in-out infinite;
    overflow: hidden;
}

.td-logo-inner svg {
    width: 56px;
    height: 56px;
}

.td-logo-text {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--td-primary) 0%, var(--td-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

/* ---- Message Text ---- */
.td-loader-message {
    margin: 0 0 6px;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--td-text);
    min-height: 1.4em;
    transition: opacity 0.3s ease;
}

.td-loader-sub {
    margin: 0;
    font-size: 0.82rem;
    color: var(--td-text-sub);
    font-weight: 400;
}

/* ---- Progress Dots ---- */
.td-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
}

.td-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--td-accent);
    opacity: 0.25;
    animation: td-dot-bounce 1.4s ease-in-out infinite;
}

.td-dot:nth-child(2) { animation-delay: 0.16s; }
.td-dot:nth-child(3) { animation-delay: 0.32s; }

/* ---- Top Progress Bar ---- */
.td-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--td-cyan) 0%, var(--td-accent) 55%, var(--td-success) 100%);
    box-shadow: 0 0 14px rgba(6, 214, 242, 0.5);
    z-index: 12100;
    transition: width 0.25s ease;
    border-radius: 0 2px 2px 0;
}

/* ============================================================
   SUCCESS STATE
   ============================================================ */
.td-status-overlay {
    position: fixed;
    inset: 0;
    z-index: 12050;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--td-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.35s ease;
    font-family: 'Poppins', sans-serif;
}

.td-status-overlay.td-visible {
    display: flex;
}

.td-status-overlay.td-fade-in {
    opacity: 1;
}

.td-status-card {
    width: min(88vw, 340px);
    background: #fff;
    border-radius: 24px;
    padding: 40px 28px 32px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(5, 12, 30, 0.35);
    transform: scale(0.85);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(.34, 1.56, .64, 1),
                opacity 0.35s ease;
}

.td-status-overlay.td-fade-in .td-status-card {
    transform: scale(1);
    opacity: 1;
}

/* Icon circle */
.td-status-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.td-status-icon.td-success {
    color: var(--td-success);
    background: rgba(16, 185, 129, 0.12);
}

.td-status-icon.td-error {
    color: var(--td-error);
    background: rgba(239, 68, 68, 0.12);
}

/* Checkmark SVG animation */
.td-check-svg {
    width: 44px;
    height: 44px;
}

.td-check-svg .td-check-circle {
    fill: none;
    stroke: var(--td-success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: td-draw-circle 0.6s ease forwards;
}

.td-check-svg .td-check-path {
    fill: none;
    stroke: var(--td-success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: td-draw-check 0.4s 0.4s ease forwards;
}

/* Error X animation */
.td-error-svg {
    width: 44px;
    height: 44px;
}

.td-error-svg .td-error-circle {
    fill: none;
    stroke: var(--td-error);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: td-draw-circle 0.6s ease forwards;
}

.td-error-svg line {
    stroke: var(--td-error);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: td-draw-x 0.3s 0.45s ease forwards;
}

.td-status-message {
    margin: 0 0 6px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--td-text);
}

.td-status-sub {
    margin: 0 0 18px;
    font-size: 0.85rem;
    color: var(--td-text-sub);
}

.td-retry-btn {
    display: none;
    margin: 12px auto 0;
    padding: 10px 32px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--td-primary) 0%, var(--td-accent) 100%);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.td-retry-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(46, 134, 222, 0.35);
}

.td-retry-btn:active {
    transform: translateY(0);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes td-ring-spin {
    to { transform: rotate(360deg); }
}

@keyframes td-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

@keyframes td-dot-bounce {
    0%, 80%, 100% { opacity: 0.25; transform: scale(1); }
    40%           { opacity: 1; transform: scale(1.35); }
}

@keyframes td-draw-circle {
    to { stroke-dashoffset: 0; }
}

@keyframes td-draw-check {
    to { stroke-dashoffset: 0; }
}

@keyframes td-draw-x {
    to { stroke-dashoffset: 0; }
}

@keyframes td-fade-text {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ============================================================
   DARK MODE SUPPORT
   ============================================================ */
[data-theme="dark"] .td-loader-card,
[data-theme="dark"] .td-status-card {
    background: rgba(20, 30, 55, 0.97);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        var(--td-neon);
}

[data-theme="dark"] .td-logo-inner {
    background: linear-gradient(145deg, #1a2a4a 0%, #0e1a35 100%);
}

[data-theme="dark"] .td-logo-text {
    background: linear-gradient(135deg, #fff 0%, var(--td-cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="dark"] .td-loader-message,
[data-theme="dark"] .td-status-message {
    color: #e2e8f0;
}

[data-theme="dark"] .td-loader-sub,
[data-theme="dark"] .td-status-sub {
    color: #94a3b8;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 576px) {
    .td-loader-card,
    .td-status-card {
        width: min(92vw, 320px);
        padding: 32px 20px 28px;
        border-radius: 20px;
    }

    .td-logo-wrap {
        width: 90px;
        height: 90px;
        margin-bottom: 20px;
    }

    .td-logo-text {
        font-size: 22px;
    }

    .td-logo-inner svg {
        width: 44px;
        height: 44px;
    }

    .td-status-icon {
        width: 68px;
        height: 68px;
    }

    .td-check-svg,
    .td-error-svg {
        width: 36px;
        height: 36px;
    }
}

/* ============================================================
   BACKWARD COMPAT — old global-loader page-load spinner
   ============================================================ */
#global-loader {
    display: none !important;
}
