/*
 * Central theme file - single source of truth for color/spacing tokens.
 * Change a value here and it propagates across the whole app: the shared
 * layout, sidebar, topbar, login page, dashboard, and every page that uses
 * the .gradient-card-* / .soft-card classes below.
 */

:root {
    /* ---- Brand palette (Soft SaaS: indigo/violet accent) ---- */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #16a34a;
    --info: #0ea5e9;
    --warning: #f59e0b;
    --danger: #e11d48;
    --light: #f8fafc;
    --dark: #1e293b;

    /* ---- Surfaces / neutrals ---- */
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --page-bg: #f4f6fb;
    --border: #e6e9f2;
    --text: #1e293b;
    --text-muted: #64748b;

    /* ---- Gradients (used by .gradient-card-*, kept for the ~75 pages
       that already use these classes as header/banner/button accents) ---- */
    --gradient-primary: linear-gradient(135deg, #6366f1, #4338ca);
    --gradient-secondary: linear-gradient(135deg, #94a3b8, #475569);
    --gradient-success: linear-gradient(135deg, #34d399, #059669);
    --gradient-warning: linear-gradient(135deg, #fbbf24, #d97706);
    --gradient-info: linear-gradient(135deg, #38bdf8, #0284c7);
    --gradient-danger: linear-gradient(135deg, #fb7185, #be123c);

    /* ---- Scales ---- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.12);
}

/* ---- Map onto Bootstrap's own variables so native components (buttons,
   focus rings, links, pagination) follow the accent automatically ---- */
:root {
    --bs-primary: var(--primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-focus-ring-color: rgba(79, 70, 229, 0.25);
    --bs-body-bg: var(--page-bg);
    --bs-body-color: var(--text);
}

body {
    background: var(--page-bg);
    color: var(--text);
}

a {
    color: var(--primary);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

    .btn-primary:hover,
    .btn-primary:focus,
    .btn-primary:active {
        background-color: var(--primary-dark) !important;
        border-color: var(--primary-dark) !important;
    }

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color);
}

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform .25s ease, box-shadow .25s ease;
    margin-bottom: 20px;
}

    .card:hover {
        box-shadow: var(--shadow-lg);
    }

/* ---- Gradient banner/header/button accents (kept for backward
   compatibility with the many existing pages using these classes) ---- */
.gradient-card-primary { background: var(--gradient-primary); color: #fff; }
.gradient-card-secondary { background: var(--gradient-secondary); color: #fff; }
.gradient-card-success { background: var(--gradient-success); color: #fff; }
.gradient-card-warning { background: var(--gradient-warning); color: #fff; }
.gradient-card-info { background: var(--gradient-info); color: #fff; }
.gradient-card-danger { background: var(--gradient-danger); color: #fff; }

.stat-card .card-body { padding: 1.5rem; }
.stat-card i { font-size: 2.5rem; opacity: .8; }

/* ---- Soft-card idiom: white card, colored icon chip, big number ----
   Used by the redesigned dashboard and Assign Permission/Menu screens. */
.soft-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s ease, transform .2s ease;
}

    .soft-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

.icon-chip {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.icon-chip-primary { background: var(--primary-light); color: var(--primary); }
.icon-chip-success { background: #dcfce7; color: var(--success); }
.icon-chip-info { background: #e0f2fe; color: var(--info); }
.icon-chip-warning { background: #fef3c7; color: var(--warning); }
.icon-chip-danger { background: #ffe4e6; color: var(--danger); }
.icon-chip-secondary { background: #f1f5f9; color: var(--secondary); }

/* ---- Toggle switch (used by Assign Permission / Assign Menu) ---- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #e2e8f0;
    transition: .2s;
    border-radius: 999px;
}

    .toggle-slider::before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
        background-color: #fff;
        transition: .2s;
        border-radius: 50%;
        box-shadow: 0 1px 3px rgba(0,0,0,.2);
    }

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(18px);
    }

.toggle-switch input:disabled + .toggle-slider {
    opacity: .6;
    cursor: not-allowed;
}

/* ---- Permission accordion (collapsible modules on Assign Permission) ---- */
.permission-accordion .accordion-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.permission-accordion .accordion-header {
    display: flex;
    align-items: stretch;
}

.permission-accordion .accordion-button {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    padding: 1rem 1.25rem;
    box-shadow: none !important;
    flex: 1 1 auto;
    width: auto;
}

.permission-accordion .module-select-all {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .5rem 1.25rem;
    border-left: 1px solid var(--border);
    background: var(--surface);
}

    .permission-accordion .accordion-button:not(.collapsed) {
        background: var(--primary-light);
        color: var(--primary-dark);
    }

    .permission-accordion .accordion-button::after {
        margin-left: .75rem;
    }

.permission-accordion .accordion-body {
    padding: 1rem 1.25rem 1.25rem;
}

.permission-accordion .module-badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    margin-left: .6rem;
}

/* ---- Sidebar (overrides the theme's hardcoded #3d5ee1 accent with --primary,
   and swaps the left-bar active style for a rounded pill highlight) ---- */
#sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: none;
}

#sidebar .sidebar-menu {
    padding: 18px 14px;
}

    #sidebar .sidebar-menu li.menu-title span {
        color: var(--text-muted);
        font-weight: 700;
        font-size: 13px;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

        #sidebar .sidebar-menu li.menu-title span i {
            color: var(--primary);
        }

    #sidebar .sidebar-menu > ul > li {
        margin-bottom: 4px;
    }

    #sidebar .sidebar-menu li a {
        color: var(--text-muted);
        border-radius: var(--radius-md);
        font-weight: 500;
    }

    #sidebar .sidebar-menu li a:hover {
        background: var(--primary-light) !important;
        color: var(--primary) !important;
        margin: 0 !important;
        padding-left: 20px !important;
    }

    #sidebar .sidebar-menu > ul > li > a:hover {
        background-color: var(--primary-light) !important;
        color: var(--primary) !important;
        margin: 0 !important;
        padding-left: 20px !important;
    }

    #sidebar .sidebar-menu li.active > a,
    #sidebar .sidebar-menu li.active > a.subdrop {
        background-color: var(--primary-light) !important;
        color: var(--primary) !important;
        font-weight: 600;
        margin: 0 !important;
        padding-left: 20px !important;
    }

        #sidebar .sidebar-menu li.active > a::before {
            display: none;
        }

    #sidebar .sidebar-menu ul ul a.active,
    #sidebar .sidebar-menu ul ul li.active > a {
        background: var(--primary) !important;
        color: #fff !important;
        border-radius: var(--radius-sm) !important;
    }

    #sidebar .sidebar-menu ul ul a {
        border-radius: var(--radius-sm);
    }

@media (max-width: 991.98px) {
    #sidebar .sidebar-menu {
        padding: 14px 10px;
    }
}

/* ---- TopBar: light touch-up for cohesion with the new sidebar ---- */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: none !important;
}

    .header .header-left {
        box-shadow: none !important;
        border-right: 1px solid var(--border);
    }

.top-nav-search .form-control {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

    .top-nav-search .form-control:focus {
        background: var(--surface);
        border-color: var(--primary);
    }

.user-menu .dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.user-menu .nav-link:hover,
.user-menu .dropdown-toggle:hover {
    color: var(--primary);
}

/* ---- Soft icon buttons (row actions in tables) ---- */
.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    flex-shrink: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}

    .icon-btn:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }

.icon-btn-primary { background: var(--primary-light); color: var(--primary); }
.icon-btn-info { background: #e0f2fe; color: var(--info); }
.icon-btn-success { background: #dcfce7; color: var(--success); }
.icon-btn-warning { background: #fef3c7; color: var(--warning); }
.icon-btn-danger { background: #ffe4e6; color: var(--danger); }
.icon-btn-secondary { background: #f1f5f9; color: var(--secondary); }

.icon-btn-group {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* ---- Detail rows (label:value pairs on details/profile-style pages) ---- */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
}

    .detail-row:last-child {
        border-bottom: none;
    }

.detail-label {
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.detail-section-title {
    color: var(--primary);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 1rem 0 .5rem;
}

/* ---- Dashboard ---- */
.dashboard-hero {
    background: var(--gradient-primary);
    color: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.stat-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.4rem;
}

.stat-tile-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.stat-tile-label {
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 500;
    margin-bottom: .2rem;
}

.stat-tile-caption {
    font-size: .78rem;
    font-weight: 600;
}

.stage-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem .5rem;
    text-align: center;
    transition: all .2s ease;
}

    .stage-tile:hover {
        border-color: var(--primary);
        background: var(--primary-light);
        transform: translateY(-2px);
    }

.activity-item {
    border-left: 3px solid var(--border);
    padding: .6rem .9rem;
    margin-bottom: .6rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: background-color .2s ease;
}

    .activity-item:hover {
        background-color: var(--surface-muted);
    }

.chart-container {
    position: relative;
    height: 300px;
}
