/* ============================================================
   COMESA Court of Justice - ECMS Stylesheet
   Palette:
     Primary:   #009CDE (CCJ Logo Blue)
     Secondary: #3870c3 (Blue Accent)
     Accent:    #28a745 (Green)
     Light BG:  #F8F9FA
     Dark BG:   #111827
   ============================================================ */

:root {
    --ccj-primary:     #009CDE;
    --ccj-primary-dk:  #007aae;
    --ccj-primary-lt:  #1ab2f0;
    --ccj-gold:        #3870c3;
    --ccj-gold-lt:     #5a87d4;
    --ccj-green:       #1a7a3e;
    --ccj-light:       #F8F9FA;
    --ccj-dark:        #111827;
    --ccj-border:      #dee2e6;
    --ccj-text:        #212529;
    --ccj-text-muted:  #6c757d;
    --bs-primary:      #009CDE;
    --bs-primary-rgb:  0, 156, 222;
}

/* ============================================================
   GLOBAL RESETS & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--ccj-light);
    color: var(--ccj-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--ccj-primary); text-decoration: none; }
a:hover { color: var(--ccj-primary-lt); text-decoration: none; }

/* ============================================================
   NAVBAR (public pages — login, register, index)
   ============================================================ */
.ccj-navbar {
    background: #ffffff;
    border-bottom: 3px solid var(--ccj-gold);
    box-shadow: 0 2px 16px rgba(0,0,0,0.1);
    z-index: 1050;
}
.ccj-navbar .navbar-brand { color: var(--ccj-primary) !important; font-size: 1.1rem; }
.ccj-navbar .nav-link { color: var(--ccj-primary) !important; font-size: 0.92rem; padding: 0.5rem 0.75rem; border-radius: 6px; transition: all 0.2s; font-weight: 500; }
.ccj-navbar .nav-link:hover, .ccj-navbar .nav-link.active { color: var(--ccj-primary) !important; background: rgba(0,156,222,0.08); }
.ccj-navbar .dropdown-menu { border: none; box-shadow: 0 8px 24px rgba(0,0,0,0.15); border-radius: 10px; }
.ccj-navbar .dropdown-item:hover { background: var(--ccj-light); color: var(--ccj-primary); }
.ccj-navbar-spacer { height: 70px; }

/* ============================================================
   TOPBAR (authenticated staff/judicial layout)
   ============================================================ */
.ccj-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 3px solid var(--ccj-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1050;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.ccj-topbar-spacer { height: 60px; }

.ccj-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hamburger toggle */
.ccj-sidebar-toggle {
    width: 38px; height: 38px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--ccj-primary);
    transition: background 0.2s;
    flex-shrink: 0;
}
.ccj-sidebar-toggle:hover { background: rgba(0,156,222,0.1); }

/* Brand */
.ccj-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ccj-primary);
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
}
.ccj-topbar-brand:hover { color: var(--ccj-primary-lt); }

/* Right section */
.ccj-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Icon buttons (notifications) */
.ccj-topbar-icon-btn {
    width: 38px; height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ccj-primary);
    text-decoration: none;
    transition: background 0.2s;
    position: relative;
}
.ccj-topbar-icon-btn:hover { background: rgba(0,156,222,0.1); color: var(--ccj-primary); }

.ccj-topbar-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: #dc3545;
    color: #fff;
    border-radius: 20px;
    font-size: 0.58rem;
    min-width: 16px; height: 16px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    font-weight: 700;
    line-height: 1;
}

/* User button */
.ccj-topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--ccj-text);
}
.ccj-topbar-user-btn:hover { background: rgba(0,156,222,0.08); }
.ccj-topbar-user-btn::after { display: none; } /* hide default Bootstrap caret */

.ccj-topbar-user-info { text-align: left; }
.ccj-topbar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ccj-text);
    line-height: 1.25;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ccj-topbar-user-role {
    font-size: 0.68rem;
    color: var(--ccj-text-muted);
    line-height: 1;
}
.ccj-topbar-caret { font-size: 0.7rem; color: #aaa; }

/* Mobile overlay for sidebar */
.ccj-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1039;
    cursor: pointer;
}

/* User avatar circle */
.ccj-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--ccj-gold);
    color: var(--ccj-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.ccj-btn-primary {
    background: var(--ccj-primary);
    border-color: var(--ccj-primary);
    color: #fff;
}
.ccj-btn-primary:hover {
    background: var(--ccj-primary-lt);
    border-color: var(--ccj-primary-lt);
    color: #fff;
}
.ccj-btn-gold {
    background: var(--ccj-gold);
    border-color: var(--ccj-gold);
    color: #fff;
    font-weight: 600;
}
.ccj-btn-gold:hover {
    background: var(--ccj-gold-lt);
    border-color: var(--ccj-gold-lt);
    color: #fff;
}

/* ============================================================
   PUBLIC / LOGIN PAGE
   ============================================================ */
.ccj-public-bg {
    background: linear-gradient(160deg, var(--ccj-primary) 0%, var(--ccj-primary-dk) 55%, #0d1233 100%);
    min-height: 100vh;
}

.ccj-hero {
    background: linear-gradient(160deg, var(--ccj-primary) 0%, var(--ccj-primary-dk) 55%, #0d1233 100%);
    color: #fff;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.ccj-hero::before {
    content: '';
    position: absolute;
    top: -50%; left: -20%;
    width: 140%; height: 140%;
    background: radial-gradient(ellipse at 30% 50%, rgba(56,112,195,0.08) 0%, transparent 60%);
    pointer-events: none;
}

/* Public nav bar */
.ccj-pub-navbar {
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.ccj-pub-navbar .navbar-brand, .ccj-pub-navbar .nav-link { color: #fff !important; }
.ccj-pub-navbar .nav-link:hover { color: var(--ccj-gold) !important; }
.ccj-pub-navbar .btn-outline-light:hover { background: var(--ccj-gold); border-color: var(--ccj-gold); color: #fff; }

/* Login card */
.ccj-login-card {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    overflow: hidden;
    max-width: 460px;
    width: 100%;
}
.ccj-login-card .card-header-custom {
    background: var(--ccj-primary);
    color: #fff;
    padding: 1.8rem 2rem 1.5rem;
    text-align: center;
}
.ccj-login-card .card-body { padding: 2rem; }

/* Feature tiles (public portal) */
.ccj-feature-tile {
    background: #ffffff;
    border: 1px solid rgba(56,112,195,0.18);
    border-radius: 14px;
    padding: 1.8rem 1.5rem;
    color: #3870c3;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: block;
    height: 100%;
}
.ccj-feature-tile:hover {
    background: #f0f5ff;
    border-color: var(--ccj-gold);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(56,112,195,0.2);
    color: #3870c3;
    text-decoration: none;
}
.ccj-feature-tile .tile-icon {
    width: 56px; height: 56px;
    background: var(--ccj-gold);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 1rem;
}
.ccj-feature-tile h5 { font-weight: 700; margin-bottom: 0.4rem; }
.ccj-feature-tile p { font-size: 0.87rem; opacity: 0.8; margin: 0; }
.ccj-feature-tile .btn-explore {
    margin-top: 1rem;
    border: 1px solid #3870c3;
    color: #3870c3;
    background: #fff;
    border-radius: 20px;
    font-size: 0.8rem;
    padding: 0.25rem 1rem;
    transition: all 0.2s;
}
.ccj-feature-tile:hover .btn-explore { background: var(--ccj-gold); border-color: var(--ccj-gold); color: #fff; }

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.ccj-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.ccj-card .card-body { color: var(--ccj-primary); }
.ccj-card .card-header {
    background: var(--ccj-primary);
    color: #fff;
    font-weight: 600;
    padding: 0.85rem 1.25rem;
    border-bottom: none;
}
.ccj-card .card-header.gold { background: var(--ccj-gold); }
.ccj-card .card-header.light {
    background: var(--ccj-light);
    color: var(--ccj-primary);
    border-bottom: 2px solid var(--ccj-primary);
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.ccj-stat-card {
    border-radius: 14px;
    padding: 1.5rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transition: transform 0.2s;
}
.ccj-stat-card:hover { transform: translateY(-3px); }
.ccj-stat-card::after {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 100px; height: 100px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}
.ccj-stat-card .stat-icon {
    font-size: 2.2rem;
    opacity: 0.9;
}
.ccj-stat-card .stat-number {
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1;
}
.ccj-stat-card .stat-label { font-size: 0.85rem; opacity: 0.85; margin-top: 0.25rem; }
.ccj-stat-primary,
.ccj-stat-gold,
.ccj-stat-green,
.ccj-stat-dark,
.ccj-stat-info,
.ccj-stat-danger  { background: linear-gradient(135deg, #009cde, #0d6efd); }

/* ============================================================
   SIDEBAR (Admin) — fixed, collapsible
   ============================================================ */
.ccj-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--ccj-primary-dk);
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease;
    z-index: 1040;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.ccj-sidebar::-webkit-scrollbar { width: 4px; }
.ccj-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.ccj-sidebar .sidebar-section {
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.ccj-sidebar .sidebar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    padding: 0.75rem 1.25rem 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s, height 0.2s;
}
.ccj-sidebar .nav-link {
    color: rgba(255,255,255,0.78);
    padding: 0.6rem 1.25rem;
    border-radius: 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.18s;
    white-space: nowrap;
    overflow: hidden;
}
.ccj-sidebar .nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.ccj-sidebar .nav-link.active {
    background: rgba(0,156,222,0.2);
    color: #fff;
    border-right: 3px solid var(--ccj-primary);
    font-weight: 600;
}
.ccj-sidebar .nav-link .bi { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* Layout — uses margin-left to offset sidebar */
.ccj-layout {
    margin-left: 260px;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.25s ease;
}
.ccj-main { padding: 1.5rem; }

/* ── Collapsed sidebar (desktop) ── */
.ccj-layout.sidebar-collapsed { margin-left: 64px; }
.ccj-layout.sidebar-collapsed .ccj-sidebar { width: 64px; }

/* Hide text, show only icons */
.ccj-layout.sidebar-collapsed .ccj-sidebar .nav-link {
    font-size: 0;       /* hides text nodes */
    padding: 0.7rem 0;
    justify-content: center;
    gap: 0;
}
.ccj-layout.sidebar-collapsed .ccj-sidebar .nav-link .bi {
    font-size: 1.2rem;
    width: auto;
}
.ccj-layout.sidebar-collapsed .ccj-sidebar .nav-link .badge { display: none; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-label { height: 0; padding: 0; opacity: 0; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-user-text { display: none; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-user-panel { justify-content: center; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-bottom-text { display: none; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-version { display: none; }
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-bottom .nav-link {
    font-size: 0;
    padding: 0.7rem 0;
    justify-content: center;
    gap: 0;
}
.ccj-layout.sidebar-collapsed .ccj-sidebar .sidebar-bottom .nav-link .bi { font-size: 1.1rem; width: auto; }

/* ============================================================
   TABLES
   ============================================================ */
.ccj-table {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ccj-table thead th {
    background: var(--ccj-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.85rem 1rem;
    border: none;
    white-space: nowrap;
}
.ccj-table tbody tr { transition: background 0.15s; }
.ccj-table tbody tr:hover { background: rgba(0,156,222,0.04); }
.ccj-table tbody td { padding: 0.75rem 1rem; vertical-align: middle; border-color: var(--ccj-border); font-size: 0.9rem; color: var(--ccj-primary); }

/* ============================================================
   FORMS
   ============================================================ */
.ccj-form-label { font-weight: 600; font-size: 0.87rem; color: var(--ccj-primary); margin-bottom: 0.3rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--ccj-primary);
    box-shadow: 0 0 0 0.2rem rgba(0,156,222,0.18);
}
.ccj-step-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
    overflow-x: auto;
}
.ccj-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}
.ccj-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--ccj-border);
    z-index: 0;
}
.ccj-step.done::after   { background: var(--ccj-primary); }
.ccj-step-circle {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--ccj-border);
    color: var(--ccj-text-muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    position: relative; z-index: 1;
    transition: all 0.2s;
}
.ccj-step.active .ccj-step-circle { background: var(--ccj-primary); color: #fff; box-shadow: 0 0 0 4px rgba(0,156,222,0.2); }
.ccj-step.done .ccj-step-circle   { background: var(--ccj-green); color: #fff; }
.ccj-step-label { font-size: 0.7rem; margin-top: 0.35rem; color: var(--ccj-text-muted); text-align: center; }
.ccj-step.active .ccj-step-label { color: var(--ccj-primary); font-weight: 600; }

/* ============================================================
   CASE NUMBER BADGE
   ============================================================ */
.ccj-case-number {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 0.88rem;
    background: var(--ccj-primary);
    color: #fff;
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    letter-spacing: 0.03em;
}

/* ============================================================
   COMPLIANCE CHECKLIST
   ============================================================ */
.ccj-checklist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--ccj-border);
}
.ccj-checklist-item:last-child { border-bottom: none; }
.ccj-check-icon { font-size: 1.2rem; }
.ccj-check-icon.pass { color: var(--ccj-green); }
.ccj-check-icon.fail { color: #dc3545; }
.ccj-check-icon.pending { color: var(--ccj-gold); }

/* ============================================================
   TIMELINE
   ============================================================ */
.ccj-timeline { position: relative; padding-left: 2rem; }
.ccj-timeline::before {
    content: '';
    position: absolute;
    left: 0.7rem; top: 0; bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--ccj-primary), var(--ccj-border));
}
.ccj-timeline-item { position: relative; padding-bottom: 1.5rem; }
.ccj-timeline-dot {
    position: absolute;
    left: -1.65rem; top: 0.15rem;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--ccj-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--ccj-primary);
}
.ccj-timeline-content {
    background: #fff;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* ============================================================
   NOTIFICATION BADGE OVERRIDE
   ============================================================ */
.badge { font-size: 0.75rem; font-weight: 600; }

/* ============================================================
   PAGE HEADERS
   ============================================================ */
.ccj-page-header {
    background: linear-gradient(135deg, var(--ccj-primary), var(--ccj-primary-lt));
    color: #fff;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: 0 4px 16px rgba(0,156,222,0.25);
}
.ccj-page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.ccj-page-header .breadcrumb { margin: 0; background: transparent; padding: 0; }
.ccj-page-header .breadcrumb-item a { color: rgba(255,255,255,0.75); }
.ccj-page-header .breadcrumb-item.active { color: rgba(255,255,255,0.55); }
.ccj-page-header .breadcrumb-item + .breadcrumb-item::before { color: rgba(255,255,255,0.5); }

/* ============================================================
   ALERTS
   ============================================================ */
.ccj-alert {
    border-radius: 10px;
    border-left: 5px solid;
    font-size: 0.9rem;
}
.ccj-alert.alert-success { border-left-color: #28a745; }
.ccj-alert.alert-danger  { border-left-color: #dc3545; }
.ccj-alert.alert-warning { border-left-color: var(--ccj-gold); }
.ccj-alert.alert-info    { border-left-color: #0d6efd; }

/* ============================================================
   FOOTER
   ============================================================ */
.ccj-footer {
    background: var(--ccj-primary-dk);
    color: rgba(255,255,255,0.6);
    margin-top: auto;
}
.ccj-footer .text-muted { color: rgba(255,255,255,0.5) !important; }
.ccj-footer img { box-shadow: none !important; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.ccj-loading-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 9998;
}
.ccj-spinner {
    width: 54px; height: 54px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: var(--ccj-gold);
    border-radius: 50%;
    animation: ccjSpin 0.7s linear infinite;
}
@keyframes ccjSpin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 991.98px) {
    /* Sidebar slides in from left on mobile */
    .ccj-sidebar {
        transform: translateX(-260px);
        width: 260px !important; /* always full width on mobile */
        transition: transform 0.25s ease;
        box-shadow: none;
    }
    .ccj-layout { margin-left: 0 !important; }
    .ccj-layout.sidebar-open .ccj-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .ccj-layout.sidebar-open .ccj-sidebar-overlay { display: block; }
    .ccj-main    { padding: 1rem; }
    .ccj-page-header { padding: 1rem 1.25rem; }
    .ccj-page-header h1 { font-size: 1.2rem; }
    .ccj-stat-card { margin-bottom: 1rem; }
    .ccj-navbar-spacer { height: 56px; }
}

@media (max-width: 575.98px) {
    .ccj-login-card { margin: 0.5rem; border-radius: 12px; }
    .ccj-login-card .card-body { padding: 1.5rem; }
    .ccj-feature-tile { padding: 1.25rem 1rem; }
    .ccj-table { font-size: 0.82rem; }
    .ccj-table thead th, .ccj-table tbody td { padding: 0.6rem 0.6rem; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .ccj-navbar, .ccj-sidebar, .ccj-footer, .btn, .breadcrumb { display: none !important; }
    .ccj-main { padding: 0; }
    body { background: #fff; }
}
