/* ==========================================================================
   AeroGuard AC — Premium Control Panel Theme
   WaveShield / FiveGuard inspired dark glass design system
   ========================================================================== */

:root {
    --ag-bg: #05070e;
    --ag-bg-soft: #070b14;
    --ag-panel: rgba(13, 20, 36, 0.72);
    --ag-panel-solid: #0b1120;
    --ag-border: rgba(148, 163, 184, 0.11);
    --ag-border-strong: rgba(148, 163, 184, 0.22);
    --ag-text: #e2e8f0;
    --ag-muted: #94a3b8;
    --ag-cyan: #22d3ee;
    --ag-sky: #38bdf8;
    --ag-violet: #8b5cf6;
    --ag-indigo: #6366f1;
    --ag-emerald: #34d399;
    --ag-amber: #fbbf24;
    --ag-rose: #fb7185;
    --ag-orange: #fb923c;
    --ag-radius: 1.15rem;
    --ag-radius-sm: 0.8rem;
    --ag-shadow: 0 24px 60px -28px rgba(2, 6, 23, 0.9);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--ag-bg);
    color: var(--ag-text);
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgba(139, 92, 246, 0.35); color: #fff; }

.mono, code, kbd, pre { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

/* --------------------------------------------------------------------------
   Background decoration
   -------------------------------------------------------------------------- */
.ag-bg-grid {
    background-image:
        linear-gradient(to right, rgba(56, 189, 248, 0.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(56, 189, 248, 0.045) 1px, transparent 1px);
    background-size: 44px 44px;
    background-position: center top;
}

.ag-grid-fade {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(900px 500px at 78% -8%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(800px 520px at 8% 110%, rgba(34, 211, 238, 0.12), transparent 60%),
        linear-gradient(180deg, rgba(5, 7, 14, 0) 0%, rgba(5, 7, 14, 0.55) 100%);
}

.ag-orb-1,
.ag-orb-2 {
    position: fixed;
    border-radius: 9999px;
    pointer-events: none;
    z-index: 0;
    filter: blur(10px);
    animation: floatOrb 16s ease-in-out infinite;
}

.ag-orb-1 {
    top: -160px;
    right: -120px;
    width: 520px;
    height: 520px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.18), transparent 68%);
}

.ag-orb-2 {
    bottom: -180px;
    left: -140px;
    width: 560px;
    height: 560px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.16), transparent 68%);
    animation-direction: reverse;
}

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(28px, -22px) scale(1.06); }
    66% { transform: translate(-22px, 18px) scale(0.96); }
}

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

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

@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* --------------------------------------------------------------------------
   Brand & text helpers
   -------------------------------------------------------------------------- */
.ag-logo-mark {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 55%, #8b5cf6 100%);
    box-shadow: 0 10px 30px -8px rgba(99, 102, 241, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.ag-gradient-text {
    background: linear-gradient(92deg, #67e8f9 0%, #38bdf8 35%, #a78bfa 75%, #c4b5fd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ag-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.10);
    border: 1px solid rgba(129, 140, 248, 0.25);
}

.ag-live-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 9999px;
    background: #34d399;
    animation: pulseRing 2s infinite;
}

.ag-mini-stat {
    padding: 0.85rem 1rem;
    border-radius: var(--ag-radius-sm);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--ag-border);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.ag-card {
    position: relative;
    background: var(--ag-panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}

.ag-card-hover:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.32);
    box-shadow: 0 28px 70px -30px rgba(14, 165, 233, 0.35);
}

.ag-card-glow::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.55), rgba(139, 92, 246, 0.45), transparent 60%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.ag-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--ag-border);
    margin-bottom: 1.15rem;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.ag-btn-primary,
.ag-btn-ghost,
.ag-btn-danger,
.ag-btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.65rem 1.15rem;
    border-radius: 0.75rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    white-space: nowrap;
}

.ag-btn-primary {
    color: #fff;
    background: linear-gradient(100deg, #0ea5e9 0%, #6366f1 52%, #8b5cf6 100%);
    background-size: 180% 180%;
    animation: shimmerGlow 6s ease infinite;
    box-shadow: 0 12px 30px -12px rgba(99, 102, 241, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ag-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 38px -14px rgba(99, 102, 241, 0.95); }
.ag-btn-primary:active { transform: translateY(0) scale(0.985); }

.ag-btn-ghost {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.035);
    border-color: var(--ag-border);
}
.ag-btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.07); border-color: var(--ag-border-strong); }

.ag-btn-soft {
    color: #7dd3fc;
    background: rgba(56, 189, 248, 0.10);
    border-color: rgba(56, 189, 248, 0.24);
}
.ag-btn-soft:hover { background: rgba(56, 189, 248, 0.18); color: #bae6fd; }

.ag-btn-danger {
    color: #fecdd3;
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(244, 63, 94, 0.30);
}
.ag-btn-danger:hover { background: rgba(244, 63, 94, 0.24); color: #fff; }

.ag-btn-xs { padding: 0.4rem 0.7rem; font-size: 0.72rem; border-radius: 0.6rem; }

button:disabled, .ag-btn-primary:disabled, .ag-btn-ghost:disabled, .ag-btn-danger:disabled, .ag-btn-soft:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.75);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.ag-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.45rem;
}

.ag-input,
.ag-select,
.ag-textarea,
input[type="text"].ag-input,
input[type="email"].ag-input,
input[type="password"].ag-input,
input[type="number"].ag-input {
    width: 100%;
    padding: 0.72rem 0.95rem;
    border-radius: 0.7rem;
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid var(--ag-border);
    color: #f8fafc;
    font-size: 0.86rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ag-input::placeholder, .ag-textarea::placeholder { color: #64748b; }

.ag-input:focus, .ag-select:focus, .ag-textarea:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.65);
    background: rgba(2, 6, 23, 0.85);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

.ag-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.4rem;
}

.ag-textarea { min-height: 9rem; resize: vertical; line-height: 1.55; }

.ag-input-wrap { position: relative; }
.ag-input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.05rem;
    height: 1.05rem;
    color: #64748b;
    pointer-events: none;
}
.ag-input-wrap .ag-input { padding-left: 2.55rem; }

input[type="checkbox"], input[type="radio"] { accent-color: #38bdf8; }

/* --------------------------------------------------------------------------
   Chips / badges
   -------------------------------------------------------------------------- */
.ag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.26rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid transparent;
    white-space: nowrap;
}
.ag-chip-cyan { color: #a5f3fc; background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.28); }
.ag-chip-emerald { color: #a7f3d0; background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.28); }
.ag-chip-amber { color: #fde68a; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.28); }
.ag-chip-rose { color: #fecdd3; background: rgba(244, 63, 94, 0.12); border-color: rgba(244, 63, 94, 0.30); }
.ag-chip-orange { color: #fed7aa; background: rgba(251, 146, 60, 0.12); border-color: rgba(251, 146, 60, 0.30); }
.ag-chip-violet { color: #ddd6fe; background: rgba(139, 92, 246, 0.13); border-color: rgba(139, 92, 246, 0.30); }
.ag-chip-slate { color: #cbd5e1; background: rgba(148, 163, 184, 0.10); border-color: rgba(148, 163, 184, 0.22); }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.ag-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: 0.8rem;
    font-size: 0.82rem;
    line-height: 1.5;
    border: 1px solid transparent;
}
.ag-alert-error { color: #fecdd3; background: rgba(244, 63, 94, 0.10); border-color: rgba(244, 63, 94, 0.28); }
.ag-alert-success { color: #a7f3d0; background: rgba(52, 211, 153, 0.10); border-color: rgba(52, 211, 153, 0.28); }
.ag-alert-info { color: #bae6fd; background: rgba(56, 189, 248, 0.10); border-color: rgba(56, 189, 248, 0.28); }
.ag-alert-warn { color: #fde68a; background: rgba(251, 191, 36, 0.10); border-color: rgba(251, 191, 36, 0.28); }

/* --------------------------------------------------------------------------
   Stat cards
   -------------------------------------------------------------------------- */
.ag-stat {
    position: relative;
    overflow: hidden;
    padding: 1.15rem 1.25rem;
    border-radius: var(--ag-radius);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(8, 13, 26, 0.72));
    border: 1px solid var(--ag-border);
    box-shadow: var(--ag-shadow);
    transition: transform 0.25s ease, border-color 0.25s ease;
}
.ag-stat:hover { transform: translateY(-2px); border-color: rgba(56, 189, 248, 0.28); }
.ag-stat::after {
    content: '';
    position: absolute;
    right: -30px;
    top: -40px;
    width: 120px;
    height: 120px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.14), transparent 70%);
    pointer-events: none;
}
.ag-stat-icon {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ag-border);
    background: rgba(255, 255, 255, 0.04);
}
.ag-stat-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.ag-stat-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; }
.ag-stat-trend { font-size: 0.7rem; font-weight: 600; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.ag-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.84rem; }
.ag-table thead th {
    text-align: left;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #7c8aa0;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--ag-border);
    white-space: nowrap;
}
.ag-table tbody td {
    padding: 0.8rem 0.85rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.07);
    vertical-align: middle;
}
.ag-table tbody tr { transition: background 0.15s ease; }
.ag-table tbody tr:hover { background: rgba(56, 189, 248, 0.045); }
.ag-table tbody tr:last-child td { border-bottom: none; }

.ag-table-wrap {
    overflow-x: auto;
    border-radius: 0.9rem;
    border: 1px solid var(--ag-border);
    background: rgba(2, 6, 23, 0.25);
}

/* --------------------------------------------------------------------------
   Sidebar / shell
   -------------------------------------------------------------------------- */
.ag-shell { min-height: 100vh; }

.ag-sidebar {
    width: 17rem;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(11, 17, 32, 0.92), rgba(7, 11, 20, 0.94));
    border-right: 1px solid var(--ag-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 40;
}

.ag-sidebar-brand {
    padding: 1.35rem 1.35rem 1.1rem;
    border-bottom: 1px solid var(--ag-border);
}

.ag-nav-section {
    padding: 1rem 0.85rem 0.25rem;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #56637a;
}

.ag-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.62rem 0.85rem;
    border-radius: 0.7rem;
    font-size: 0.83rem;
    font-weight: 600;
    color: #94a3b8;
    border: 1px solid transparent;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.ag-nav-link svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.ag-nav-link:hover { color: #e2e8f0; background: rgba(148, 163, 184, 0.07); }
.ag-nav-link.active {
    color: #e0f2fe;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.14), rgba(139, 92, 246, 0.08));
    border-color: rgba(56, 189, 248, 0.28);
    box-shadow: inset 3px 0 0 #38bdf8, 0 8px 24px -18px rgba(56, 189, 248, 0.9);
}

.ag-topbar {
    height: 4.1rem;
    border-bottom: 1px solid var(--ag-border);
    background: rgba(7, 11, 20, 0.72);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.ag-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(3px);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.ag-mobile-overlay.open { opacity: 1; pointer-events: auto; }

@media (max-width: 1023px) {
    .ag-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
        width: 17.5rem;
        box-shadow: 40px 0 80px -40px rgba(0, 0, 0, 0.9);
    }
    .ag-sidebar.open { transform: translateX(0); }
}

/* --------------------------------------------------------------------------
   Auth page
   -------------------------------------------------------------------------- */
.ag-auth-page {
    background:
        radial-gradient(1000px 600px at 80% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(900px 600px at 0% 100%, rgba(34, 211, 238, 0.10), transparent 60%),
        #05070e;
}

.ag-auth-card {
    position: relative;
    padding: 2rem;
    border-radius: 1.35rem;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(8, 13, 26, 0.78));
    border: 1px solid var(--ag-border);
    box-shadow: 0 40px 90px -40px rgba(2, 6, 23, 1);
    backdrop-filter: blur(20px);
    animation: fadeInUp 0.5s ease-out both;
}

/* --------------------------------------------------------------------------
   Toasts / modals
   -------------------------------------------------------------------------- */
.ag-toast-stack {
    position: fixed;
    right: 1.1rem;
    bottom: 1.1rem;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(92vw, 24rem);
}

.ag-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 0.95rem;
    border-radius: 0.8rem;
    background: rgba(11, 17, 32, 0.96);
    border: 1px solid var(--ag-border-strong);
    box-shadow: 0 18px 45px -18px rgba(0, 0, 0, 0.9);
    font-size: 0.8rem;
    line-height: 1.45;
    color: #e2e8f0;
    animation: fadeInUp 0.25s ease-out both;
}
.ag-toast.success { border-color: rgba(52, 211, 153, 0.4); }
.ag-toast.error { border-color: rgba(244, 63, 94, 0.45); }
.ag-toast.info { border-color: rgba(56, 189, 248, 0.4); }
.ag-toast.warn { border-color: rgba(251, 191, 36, 0.45); }

.ag-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(2, 6, 23, 0.74);
    backdrop-filter: blur(6px);
    animation: fadeInUp 0.18s ease-out both;
}
.ag-modal {
    width: min(94vw, 28rem);
    padding: 1.4rem;
    border-radius: 1.15rem;
    background: #0b1120;
    border: 1px solid var(--ag-border-strong);
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 1);
}
.ag-modal-title { font-size: 1rem; font-weight: 800; color: #fff; }
.ag-modal-text { font-size: 0.82rem; color: #94a3b8; margin-top: 0.35rem; line-height: 1.55; }
.ag-modal-actions { display: flex; justify-content: flex-end; gap: 0.55rem; margin-top: 1.2rem; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.ag-divider { height: 1px; background: var(--ag-border); }

.ag-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
.ag-scroll::-webkit-scrollbar-track { background: transparent; }
.ag-scroll::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 9999px; }
.ag-scroll::-webkit-scrollbar-thumb:hover { background: #38bdf8; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #050811; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #38bdf8; }

.ag-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    border: 1px dashed var(--ag-border-strong);
    border-radius: 0.9rem;
    color: #7c8aa0;
    font-size: 0.84rem;
}

.ag-kbd {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.4rem;
    border-radius: 0.35rem;
    border: 1px solid var(--ag-border-strong);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.66rem;
    color: #cbd5e1;
}

.ag-fade-in { animation: fadeInUp 0.4s ease-out both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
