/* Google font is loaded via <link> in HTML */

:root {
    --color-primary: #f48005;
    --color-primary-soft: rgba(244, 128, 5, 0.14);
    --color-secondary: #f6b708;
    --color-accent-1: #6fedfc;
    --color-accent-2: #3390f8;

    --bg-light: #efeded;
    --bg-dark: #272727;

    --sidebar-width: 260px;
    --radius-lg: 18px;
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.18);

    --topbar-height: 64px;
    /* used for mobile offset */
}

/* Global reset-ish */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.925rem;
    line-height: 1.5;

    /* Soft AI gradient background (no repeat) */
    background:
        radial-gradient(circle at 0% 80%, rgba(244, 128, 5, 0.35), transparent 60%),
        radial-gradient(circle at 100% 10%, rgba(51, 144, 248, 0.35), transparent 55%),
        radial-gradient(circle at 0% 0%, rgba(111, 237, 252, 0.18), transparent 55%);
    background-color: var(--bg-light);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;

    color: #111;
    position: relative;
    overflow-x: hidden;
}

/* Themes */
body.theme-light {
    color: #111;
}

body.theme-dark {
    background:
        radial-gradient(circle at 0% 80%, rgba(244, 128, 5, 0.16), transparent 60%),
        radial-gradient(circle at 100% 10%, rgba(51, 144, 248, 0.18), transparent 55%),
        radial-gradient(circle at 0% 0%, rgba(111, 237, 252, 0.12), transparent 55%);
    background-color: var(--bg-dark);
    color: #f4f4f4;
}

body.theme-dark .table-light thead {
    background-color: #333 !important;
}

body.theme-dark .table {
    color: #f4f4f4;
}

body.theme-dark .app-footer {
    border-top-color: rgba(255, 255, 255, 0.06);
}

/* AI background orbits (optional decoration) */
.ai-orbit {
    position: fixed;
    inset: auto auto 10% -5%;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle at 0% 0%, rgba(244, 128, 5, 0.5), transparent 60%),
        radial-gradient(circle at 100% 100%, rgba(51, 144, 248, 0.4), transparent 55%);
    filter: blur(3px);
    opacity: 0.6;
    z-index: -1;
    animation: orbitFloat 18s ease-in-out infinite alternate;
}

.ai-orbit-2 {
    inset: -10% auto auto 55%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle at 0% 0%, rgba(111, 237, 252, 0.5), transparent 60%),
        radial-gradient(circle at 100% 100%, rgba(246, 183, 8, 0.4), transparent 55%);
    animation-duration: 24s;
}

@keyframes orbitFloat {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }

    100% {
        transform: translate3d(40px, -20px, 0) scale(1.06);
    }
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar (desktop default) */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #111, #181818);
    color: #f6f6f6;
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    align-self: stretch;
    min-height: 100vh;
    overflow-y: auto;
    box-shadow: 12px 0 45px rgba(0, 0, 0, 0.55);
    z-index: 10;
    transition: width 0.2s ease;
}

/* desktop collapsed */
body.sidebar-collapsed .sidebar {
    width: 72px;
}

body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar-link span {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
}

/* brand & nav */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.sidebar-brand i {
    font-size: 1.25rem;
    color: var(--color-accent-1);
}

.sidebar-nav {
    margin-top: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: #c2c2c2;
    text-decoration: none;
    border-radius: 999px;
    font-size: 0.9rem;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.sidebar-link i {
    font-size: 1.1rem;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent-2));
    color: #111;
    font-weight: 500;
}

.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 0.75rem 0;
}

/* Main area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(14px);
    background-color: rgba(239, 237, 237, 0.92);
    position: sticky;
    top: 0;
    z-index: 5;
}

body.theme-dark .topbar {
    background-color: rgba(25, 25, 25, 0.94);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.topbar-title h1 {
    font-weight: 600;
}

.topbar-actions .btn {
    border-radius: 999px;
}

/* Avatar */
.avatar-circle {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-accent-2), var(--color-accent-1));
    color: #111;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Page content */
.page-content {
    padding: 1.25rem;
    flex: 1;
}

/* Footer */
.app-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(14px);
    background-color: rgba(239, 237, 237, 0.92);
}

body.theme-dark .app-footer {
    background-color: rgba(25, 25, 25, 0.94);
}

/* Glass card */
.glass-card {
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(18px);
}

body.theme-dark .glass-card {
    background: rgba(25, 25, 25, 0.88);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.85);
}

/* Stat cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.bg-primary-soft {
    background: rgba(244, 128, 5, 0.15);
    color: var(--color-primary);
}

.bg-warning-soft {
    background: rgba(246, 183, 8, 0.16);
    color: var(--color-secondary);
}

.bg-info-soft {
    background: rgba(111, 237, 252, 0.2);
    color: var(--color-accent-2);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #777;
}

body.theme-dark .stat-label {
    color: #aaa;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.stat-trend {
    font-size: 0.75rem;
}

/* AI pulse card */
.ai-pulse-card {
    position: relative;
    overflow: hidden;
}

.ai-wave {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.25rem;
}

.ai-wave-dot {
    width: 6px;
    height: 16px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--color-accent-2), var(--color-accent-1));
    animation: aiWave 1s infinite ease-in-out;
}

.ai-wave-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-wave-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes aiWave {

    0%,
    100% {
        transform: scaleY(0.5);
        opacity: 0.5;
    }

    50% {
        transform: scaleY(1.2);
        opacity: 1;
    }
}

/* Auth pages */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-wrapper {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
}

.auth-card {
    padding: 1.75rem 1.5rem;
}

.auth-logo {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-2));
    color: #111;
    font-size: 1.4rem;
}

/* OTP */
.otp-input-group .otp-input {
    padding-inline: 0;
}

/* Language flag */
.lang-flag {
    font-size: 1rem;
}

/* Utility tweaks */
.table> :not(caption)>*>* {
    padding: 0.55rem 0.75rem;
}

.badge.bg-success-subtle {
    background-color: rgba(25, 135, 84, 0.12);
}

.badge.bg-warning-subtle {
    background-color: rgba(255, 193, 7, 0.18);
}

.badge.bg-danger-subtle {
    background-color: rgba(220, 53, 69, 0.16);
}

.badge.bg-info-soft {
    background-color: rgba(111, 237, 252, 0.18);
}

/* Buttons using your color palette */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border: none;
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.btn-outline-secondary {
    border-color: rgba(0, 0, 0, 0.18);
}

body.theme-dark .btn-outline-secondary {
    border-color: rgba(255, 255, 255, 0.18);
    color: #f4f4f4;
}

/* Modals inside dark mode */
body.theme-dark .modal-content {
    background-color: #1b1b1b;
    color: #f4f4f4;
}

/* ----------- MOBILE BEHAVIOUR (SIDEBAR UNDER HEADER) ----------- */

@media (max-width: 991.98px) {

    /* Sidebar becomes a drawer UNDER the fixed header */
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        width: var(--sidebar-width);
        min-height: calc(100vh - var(--topbar-height));
        transform: translateX(-100%);
        box-shadow: 12px 0 45px rgba(0, 0, 0, 0.55);
        z-index: 25;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* On mobile, ignore collapsed width */
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
    }

    /* Header fixed on mobile */
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 30;
    }

    /* Push content below fixed header */
    .main-area {
        padding-top: var(--topbar-height);
    }

    .page-content {
        padding-top: 1rem;
    }
}

/* Admin group radio cards */
.admin-group-card {
    display: block;
    cursor: pointer;
    user-select: none;
}

.admin-group-card-body {
    border-radius: 14px;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease,
        transform 0.12s ease;
}

body.theme-dark .admin-group-card-body {
    background: rgba(20, 20, 20, 0.9);
    border-color: rgba(255, 255, 255, 0.06);
}

.admin-group-card:hover .admin-group-card-body {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.admin-group-card.active .admin-group-card-body {
    border-color: var(--color-accent-2);
    box-shadow: 0 0 0 1px rgba(51, 144, 248, 0.5);
    background: rgba(111, 237, 252, 0.07);
}

/* sites page */
/* No wrap in sites table */
.table-nowrap th,
.table-nowrap td {
    white-space: nowrap;
}

/* Amount coloring */
.amount-positive {
    color: #128b4b;
    /* green tone matching theme */
    font-weight: 600;
}

.amount-negative {
    color: #dc3545;
    font-weight: 600;
}

/* Copy buttons in table */
.btn-copy {
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.85);
    line-height: 1;
}

.btn-copy i {
    vertical-align: middle;
}

.btn-copy:hover {
    background: rgba(111, 237, 252, 0.15);
}

body.theme-dark .btn-copy {
    background: rgba(20, 20, 20, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark .btn-copy:hover {
    background: rgba(51, 144, 248, 0.2);
}

/* Tiny visual feedback when copied */
.btn-copy.copied {
    box-shadow: 0 0 0 1px rgba(51, 144, 248, 0.6);
}

/* Better compact table layout for Sites page */
.table-sites th,
.table-sites td {
    white-space: nowrap;
    padding: 0.45rem 0.55rem !important;
}

/* Narrow numeric columns */
.table-sites .col-num {
    width: 50px;
    text-align: end;
}

/* Narrow action column */
.table-sites .col-actions {
    width: 90px;
    text-align: center;
}

/* SID / KEY truncation */
.table-sites .col-sid,
.table-sites .col-key {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.amount-positive {
    color: #0f9d58 !important;
    font-weight: 600;
}

.amount-negative {
    color: #d93025 !important;
    font-weight: 600;
}

.table-sites .col-sid,
.table-sites .col-key {
    max-width: 220px;
}

.btn-copy-toggle {
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.85);
    line-height: 1;
}

.btn-copy-toggle:hover {
    background: rgba(111, 237, 252, 0.15);
}

body.theme-dark .btn-copy-toggle {
    background: rgba(20, 20, 20, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark .btn-copy-toggle:hover {
    background: rgba(51, 144, 248, 0.2);
}
.sidebar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.45);
    padding: 0.35rem 0.75rem 0.15rem;
}

.sidebar-link-sub {
    padding-left: 1.9rem; /* small indent under section */
}
