:root {
    --idts-primary: #0d2b6b;
    --idts-primary-2: #1d4ed8;
    --idts-accent: #06b6d4;
    --idts-bg: #f5f7fb;
    --idts-surface: #ffffff;
    --idts-border: #e5e7eb;
    --idts-text: #0f172a;
    --idts-muted: #64748b;
    --idts-sidebar-bg: #0d2b6b;
    --idts-sidebar-text: #e0e7ff;
    --idts-sidebar-active: #1d4ed8;
    --idts-shadow: 0 4px 24px rgba(15, 23, 42, .08);
    --idts-radius: 12px;
}

[data-theme="dark"], [data-bs-theme="dark"] {
    --idts-bg: #0b1220;
    --idts-surface: #111a2c;
    --idts-border: #1e293b;
    --idts-text: #e2e8f0;
    --idts-muted: #94a3b8;
    --idts-sidebar-bg: #060b18;
    --idts-sidebar-text: #cbd5e1;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

    body.idts-app {
        margin: 0;
        background: var(--idts-bg);
        color: var(--idts-text);
        font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
    }

        body.idts-app.is-auth {
            padding-left: 260px;
        }

        body.idts-app.is-anonymous {
            padding-left: 0;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

@media (max-width: 991.98px) {
    body.idts-app.is-auth {
        padding-left: 0;
        padding-bottom: 72px;
    }
}

/* Desktop: hamburger hides sidebar and frees full width */
@media (min-width: 992px) {
    body.idts-app.is-auth.sidebar-collapsed {
        padding-left: 0;
    }

        body.idts-app.is-auth.sidebar-collapsed .idts-sidebar {
            transform: translateX(-100%);
        }
}

/* ==== Sidebar ==== */
.idts-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--idts-sidebar-bg);
    color: var(--idts-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
    overflow-y: auto;
}

.idts-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: .04em;
}

.idts-sidebar__logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--idts-primary-2), var(--idts-accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.idts-sidebar__nav {
    padding: 12px 8px;
    flex: 1;
}

.idts-sidebar__link,
.idts-sidebar__sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--idts-sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    font-size: .92rem;
    margin: 2px 0;
    transition: background .15s ease;
}

.idts-sidebar__sublink {
    margin-left: 26px;
    font-size: .85rem;
    color: rgba(224,231,255,.78);
}

    .idts-sidebar__link:hover,
    .idts-sidebar__sublink:hover {
        background: rgba(255,255,255,.06);
        color: #fff;
    }

.idts-sidebar__link.active,
.idts-sidebar__sublink.active {
    background: var(--idts-sidebar-active);
    color: #fff;
}

.idts-sidebar__group-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 10px 14px;
    color: var(--idts-sidebar-text);
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
}

    .idts-sidebar__group-toggle .idts-sidebar__chev {
        margin-left: auto;
        transition: transform .15s ease;
        font-size: .8rem;
    }

    .idts-sidebar__group-toggle[aria-expanded="true"] .idts-sidebar__chev {
        transform: rotate(180deg);
    }

    .idts-sidebar__group-toggle:hover {
        background: rgba(255,255,255,.06);
        color: #fff;
    }

@media (max-width: 991.98px) {
    .idts-sidebar {
        transform: translateX(-100%);
    }

    body.idts-app.sidebar-open .idts-sidebar {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
}

/* ==== Topbar ==== */
.idts-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--idts-surface);
    border-bottom: 1px solid var(--idts-border);
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 14px;
    min-height: 60px;
}

/* Sidebar hamburger toggle button */
.idts-topbar__menu {
    background: transparent;
    border: 0;
    font-size: 1.2rem;
    color: var(--idts-text);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    transition: background .15s ease;
}

    .idts-topbar__menu:hover {
        background: var(--idts-bg);
        color: var(--idts-primary);
    }

/* Page title - takes remaining horizontal space */
.idts-topbar__title {
    font-weight: 600;
    flex: 1;
    font-size: 1rem;
    color: var(--idts-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Right side actions group - theme, lang, bell, user */
.idts-topbar__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Shared icon button style - used by theme, lang, notification */
.idts-topbar__icon {
    background: transparent;
    border: 0;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--idts-muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    flex-shrink: 0;
    position: relative;
}

    .idts-topbar__icon:hover {
        background: var(--idts-bg);
        color: var(--idts-primary);
    }

/* Notification bell wrapper */
.idts-topbar__notif {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Red unread dot badge on bell icon */
.idts-topbar__badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid var(--idts-surface);
    pointer-events: none;
}

/* User profile dropdown trigger button */
.idts-topbar__user {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 0;
    padding: 4px 8px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease;
    flex-shrink: 0;
    max-width: 220px;
}

    .idts-topbar__user:hover {
        background: var(--idts-bg);
    }

/* Avatar circle with user initial */
.idts-topbar__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--idts-primary), var(--idts-primary-2));
    color: #fff;
    font-weight: 700;
    font-size: .875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Full name and role label stacked vertically */
.idts-topbar__user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    overflow: hidden;
}

    .idts-topbar__user-meta span {
        font-size: .875rem;
        font-weight: 600;
        color: var(--idts-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 130px;
    }

    .idts-topbar__user-meta small {
        font-size: .75rem;
        color: var(--idts-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 130px;
    }

/* --- Responsive: tablet --- */
@media (max-width: 767.98px) {
    .idts-topbar {
        padding: 10px 14px;
        gap: 8px;
    }

    /* Hide name/role text on tablet, keep avatar only */
    .idts-topbar__user-meta {
        display: none;
    }

    .idts-topbar__user .fa-chevron-down {
        display: none;
    }

    .idts-topbar__user {
        padding: 4px;
    }
}

/* --- Responsive: mobile --- */
@media (max-width: 575.98px) {
    .idts-topbar {
        padding: 8px 12px;
        gap: 4px;
    }

    .idts-topbar__actions {
        gap: 0;
    }

    .idts-topbar__icon {
        width: 34px;
        height: 34px;
        font-size: .9rem;
    }

    .idts-topbar__avatar {
        width: 30px;
        height: 30px;
        font-size: .8rem;
    }

    /* Hide language toggle on small screens to save space */
    #idtsLangToggle {
        display: none;
    }
}

/* ==== Main content ==== */
.idts-content {
    padding: 24px;
    min-height: calc(100vh - 60px);
}

.idts-public {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    flex-direction: column;
}

.card {
    border: 1px solid var(--idts-border);
    border-radius: var(--idts-radius);
    box-shadow: var(--idts-shadow);
    background: var(--idts-surface);
}

/* ==== Floating action button ==== */
.idts-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--idts-primary), var(--idts-primary-2));
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 8px 24px rgba(13,43,107,.35);
    z-index: 1050;
}

.idts-fab-menu {
    position: fixed;
    right: 22px;
    bottom: 88px;
    background: var(--idts-surface);
    border-radius: var(--idts-radius);
    box-shadow: var(--idts-shadow);
    padding: 6px;
    z-index: 1050;
    min-width: 200px;
}

.idts-fab-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--idts-text);
    border-radius: 8px;
    font-size: .92rem;
}

    .idts-fab-menu__item:hover {
        background: var(--idts-bg);
    }

.idts-fab-menu[hidden] {
    display: none;
}

@media (max-width: 991.98px) {
    .idts-fab, .idts-fab-menu {
        bottom: 84px;
    }
}

/* ==== Mobile bottom nav ==== */
.idts-mobilenav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--idts-surface);
    border-top: 1px solid var(--idts-border);
    display: flex;
    justify-content: space-around;
    z-index: 1040;
}

.idts-mobilenav__item {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    text-decoration: none;
    color: var(--idts-muted);
    font-size: .68rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .idts-mobilenav__item i {
        font-size: 1.05rem;
    }

    .idts-mobilenav__item.active {
        color: var(--idts-primary);
    }

/* ==== Scroll-to-top ==== */
.idts-scroll-top {
    position: fixed;
    right: 22px;
    bottom: 92px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--idts-border);
    background: var(--idts-surface);
    color: var(--idts-primary);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}

    .idts-scroll-top.visible {
        opacity: 1;
        pointer-events: auto;
    }

@media (max-width: 991.98px) {
    .idts-scroll-top {
        bottom: 154px;
    }
}

/* ==== Auth pages ==== */
.idts-auth-shell {
    flex: 1;
    width: 100%;
    background: linear-gradient(135deg, #0d2b6b 0%, #1d4ed8 60%, #06b6d4 100%);
    display: grid;
    place-items: center;
    padding: 24px;
}

.idts-auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--idts-surface);
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(2,12,40,.45);
    padding: 36px 32px;
}

.idts-auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.idts-auth-brand__logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--idts-primary), var(--idts-primary-2));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.idts-auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.idts-auth-card p.lead {
    color: var(--idts-muted);
    margin-bottom: 22px;
    font-size: .95rem;
}

/* Site footer (all layouts) */
.idts-site-footer {
    text-align: center;
    padding: 12px 16px 16px;
    color: var(--idts-muted);
    font-size: .82rem;
    background: var(--idts-bg);
    flex-shrink: 0;
}

body.idts-app.is-auth .idts-site-footer {
    border-top: 1px solid var(--idts-border);
    background: var(--idts-surface);
}

.otp-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(40px, 1fr));
    gap: 10px;
    width: 100%;
}

    .otp-grid input {
        width: 100%;
        min-width: 0;
        height: 60px;
        text-align: center;
        font-size: 1.25rem;
        font-weight: 600;
        border: 1px solid var(--idts-border);
        border-radius: 8px;
    }

        .otp-grid input:focus {
            outline: 2px solid var(--idts-primary-2);
        }

/* ==== Skeleton ==== */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 37%, #e5e7eb 63%);
    background-size: 400% 100%;
    animation: idts-shimmer 1.4s infinite;
    border-radius: 6px;
}

@keyframes idts-shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* DataTables tweaks */
table.dataTable thead th {
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--idts-border);
    border-radius: 8px;
    padding: 6px 10px;
}

.idts-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

    .idts-page-header h1 {
        font-size: 1.25rem;
        margin: 0;
    }

    .idts-page-header .actions {
        margin-left: auto;
        display: flex;
        gap: 8px;
    }

/* Phase 6 — keyboard focus visibility (WCAG-friendly) */
.idts-sidebar a:focus-visible,
.idts-main a:focus-visible,
.idts-main button:focus-visible,
.idts-topbar button:focus-visible,
.idts-fab:focus-visible {
    outline: 2px solid var(--idts-primary-2);
    outline-offset: 2px;
}
