@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg:        #f0f4f8;
  --bg-card:   #ffffff;
  --bg-panel:  #f7f9fc;
  --bg-nav:    #1a2744;
  --accent:    #1a6ef5;
  --accent-dark: #1258c8;
  --accent2:   #0ea86a;
  --accent-warn: #e07b00;
  --accent-danger: #d63030;
  --text-primary: #1a2233;
  --text-muted:   #6b7a99;
  --border:    #dce4f0;
  --shadow:    0 2px 12px rgba(26,46,100,0.08);
  --shadow-lg: 0 6px 30px rgba(26,46,100,0.12);
  --radius:    10px;
  --radius-sm: 7px;

  /* Aliases — several pages reference these custom-property names directly
     with their own fallback values. Defining them here keeps every page
     visually consistent with the main theme. */
  --card-bg:        var(--bg-card);
  --card-header-bg: var(--bg-panel);
  --text:           var(--text-primary);
  --thead-bg:       var(--bg-panel);
  --row-hover:      #f4f7fd;
  --code-bg:        #eef3ff;
  --input-bg:       #ffffff;
  --accent-dark2:   var(--accent-dark);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; }

/* Lock background scroll while the mobile sidebar drawer is open */
body.sidebar-open { overflow: hidden; }
@media (min-width: 992px) { body.sidebar-open { overflow: auto; } }


/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar{
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, #1c2a4a 0%, #15203a 100%);
    overflow-y: auto;
    z-index: 1001;
    transition: left .28s ease;
    scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar{ width: 4px; }
.sidebar::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.15); border-radius: 3px; }

.sidebar-logo{
    padding: 20px;
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
}

.sidebar-logo i{
    margin-right: 10px;
    font-size: 22px;
    color: #5bc0f8;
}

/* Close (X) button shown inside the drawer on small screens */
.sidebar-close{
    display: none;
    margin-left: auto;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,.07);
    color: #c4cbe2;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.sidebar-close:hover{ background: rgba(255,255,255,.16); color: #fff; }

.sidebar-menu{
    list-style: none;
    padding: 10px 0 24px;
    margin: 0;
}

.sidebar-menu li{
    margin: 3px 12px;
}

.sidebar-menu li a{
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aab4cf;
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: .2px;
    transition: background .2s, color .2s, box-shadow .2s;
}

.sidebar-menu li a:hover{
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar-menu li a.active{
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(26,110,245,.35);
}

.sidebar-menu i{
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-sep{
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: rgba(255,255,255,.28);
    padding: 16px 18px 6px;
}

/* Dim background overlay used to close the drawer on small screens */
.sidebar-overlay{
    position: fixed;
    inset: 0;
    background: rgba(10,16,32,.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}
.sidebar-overlay.show{
    opacity: 1;
    visibility: visible;
}
@media (min-width: 992px){
    .sidebar-overlay{ display: none; }
}

/* Hamburger button — hidden on desktop, shown on small screens */
.sidebar-toggle{
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .15s, color .15s, background .15s;
}
.sidebar-toggle:hover{
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-panel);
}

/* Legacy class kept for compatibility — superseded by .sidebar-toggle */
.mobile-toggle{ display: none; }


/* =====================================================================
   TOPBAR
   ===================================================================== */
.topbar{
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 26px;
    z-index: 999;
    box-shadow: var(--shadow);
    transition: left .28s ease, padding .2s ease;
}

.topbar-left{
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-left h5{
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right{
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.topbar-username{ font-weight: 500; }


/* =====================================================================
   MAIN CONTENT
   ===================================================================== */
.main-content{
    margin-left: 260px;
    margin-top: 70px;
    padding: 24px;
    min-height: calc(100vh - 70px);
}


/* =====================================================================
   BODY-LEVEL ROLE BADGE (also styled inline on some pages)
   ===================================================================== */
.role-badge{
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    vertical-align: middle;
    white-space: nowrap;
}
.role-super { background:#f3e8ff; color:#7c3aed; }
.role-admin { background:#dbeafe; color:#1d4ed8; }
.role-dept  { background:#dcfce7; color:#166534; }


/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body { padding: 20px; }

/* STAT CARDS */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #5bc0f8);
}

.stat-number {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.2rem;
  opacity: 0.07;
  color: var(--accent);
}


/* =====================================================================
   TABLES
   ===================================================================== */
.table {
  color: var(--text-primary);
  margin-bottom: 0;
}

.table thead th {
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 12px 16px;
  white-space: nowrap;
}

.table td {
  border-color: var(--border);
  vertical-align: middle;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-primary);
}

.table tbody tr:hover td {
  background: var(--row-hover);
}

.table-responsive{
  -webkit-overflow-scrolling: touch;
}


/* =====================================================================
   BADGES
   ===================================================================== */
.badge {
  font-size: 11px;
  letter-spacing: 0.3px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
}

.badge.bg-success   { background: #d1f7e6 !important; color: #0a7a4a; }
.badge.bg-secondary { background: #e9ecf2 !important; color: #6b7a99; }
.badge.bg-warning   { background: #fff3d1 !important; color: #9a5800; }
.badge.bg-danger    { background: #ffe0e0 !important; color: #b02020; }
.badge.bg-info      { background: #ddeeff !important; color: #1254b8; }

/* Status dots */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.status-dot.online  { background: var(--accent2); }
.status-dot.offline { background: #c0cad8; }
.status-dot.warning { background: var(--accent-warn); }


/* =====================================================================
   FORMS
   ===================================================================== */
.form-control, .form-select {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  padding: 9px 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,110,245,0.1);
  outline: none;
}

.form-control::placeholder { color: #b0bdd4; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.3px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.input-group .btn-outline-secondary {
  border-left-color: var(--border);
}


/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: all 0.15s;
  border-width: 1.5px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(26,110,245,0.3);
  color: #fff;
}

.btn-success {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}
.btn-success:hover {
  background: #0a8a56;
  border-color: #0a8a56;
  box-shadow: 0 4px 12px rgba(14,168,106,0.3);
  color: #fff;
}

.btn-danger {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: #fff;
}
.btn-danger:hover {
  background: #b02020;
  border-color: #b02020;
  color: #fff;
}

.btn-warning {
  background: var(--accent-warn);
  border-color: var(--accent-warn);
  color: #fff;
}
.btn-warning:hover {
  background: #b86200;
  color: #fff;
}

.btn-info {
  background: #e8f2ff;
  border-color: #b8d4ff;
  color: var(--accent);
}
.btn-info:hover {
  background: #d0e6ff;
  color: var(--accent);
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-muted);
  background: #fff;
}
.btn-outline-secondary:hover {
  background: var(--bg-panel);
  color: var(--text-primary);
  border-color: #b0bdd4;
}

.btn-sm  { padding: 5px 11px; font-size: 11px; }
.btn-lg  { padding: 11px 26px; font-size: 14px; }

.btn-group .btn,
.btn-group-sm > .btn{
  white-space: nowrap;
}


/* =====================================================================
   ALERTS
   ===================================================================== */
.alert {
  border-radius: 8px;
  font-size: 13px;
  border-width: 1.5px;
}
.alert-success { background: #f0fdf6; border-color: #a3e8c5; color: #0a6640; }
.alert-danger  { background: #fff5f5; border-color: #f5b8b8; color: #9a1a1a; }
.alert-warning { background: #fffbf0; border-color: #ffd98a; color: #7a4c00; }
.alert-info    { background: #f0f7ff; border-color: #a8cbf8; color: #1040a0; }


/* =====================================================================
   HEADINGS
   ===================================================================== */
h2, h3, h4, h5 {
  color: var(--text-primary);
  font-weight: 600;
}

h3 {
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 2px;
  flex-shrink: 0;
}


/* =====================================================================
   PRE / CODE OUTPUT
   ===================================================================== */
pre, .cmd-output {
  background: #1a2233;
  border: 1px solid #2d3a55;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 16px;
  max-height: 450px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

code {
  background: var(--code-bg);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  word-break: break-all;
}


/* =====================================================================
   LOGIN (legacy / fallback classes — login.php has its own styles)
   ===================================================================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8eef8 0%, #f5f7fc 50%, #eaf0fb 100%);
  padding: 20px;
}

.login-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(26,46,100,0.12);
  position: relative;
  overflow: hidden;
}

.login-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #5bc0f8, var(--accent2));
}

.login-logo { text-align: center; margin-bottom: 34px; }

.login-logo h1 {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-primary);
  font-size: 1.2rem;
  letter-spacing: 2px;
  font-weight: 600;
  margin: 0;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 1px;
  margin-top: 5px;
}

.login-logo .logo-icon {
  font-size: 2.6rem;
  margin-bottom: 12px;
  display: block;
  color: var(--accent);
}


/* =====================================================================
   TABS
   ===================================================================== */
.nav-tabs {
  border-bottom: 2px solid var(--border);
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar{ display: none; }

.nav-tabs .nav-link {
  color: var(--text-muted) !important;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 20px !important;
  margin-bottom: -2px;
  white-space: nowrap;
}
.nav-tabs .nav-link.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent);
  background: transparent;
}


/* =====================================================================
   MODAL
   ===================================================================== */
.modal-content {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
}
.modal-footer { border-top: 1px solid var(--border); }
.btn-close { opacity: 0.4; }


/* =====================================================================
   PAGINATION
   ===================================================================== */
.page-link {
  background: #fff;
  border-color: var(--border);
  color: var(--text-muted);
}
.page-link:hover, .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}


/* =====================================================================
   SCROLLBAR (global)
   ===================================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #c8d4e8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }


/* =====================================================================
   MISC
   ===================================================================== */
footer { color: var(--text-muted) !important; }
.vr { background: rgba(255,255,255,0.2); }
.container { max-width: 1300px; }
.mt-4 { margin-top: 1.5rem !important; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card, .stat-card { animation: fadeInUp 0.35s ease both; }


/* =====================================================================
   RESPONSIVE — TABLET & BELOW (≤ 991px)
   Sidebar becomes an off-canvas drawer with overlay.
   ===================================================================== */
@media (max-width: 991px){
    .sidebar{
        left: -270px;
        width: 270px;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.show{ left: 0; }

    .sidebar-close{ display: flex; }
    .sidebar-toggle{ display: inline-flex; }

    .topbar{ left: 0; padding: 0 18px; }
    .main-content{ margin-left: 0; padding: 18px; }
}

@media (min-width: 992px){
    .sidebar-toggle{ display: none; }
    .sidebar-close{ display: none; }
}


/* =====================================================================
   RESPONSIVE — SMALL TABLET / LARGE PHONE (≤ 768px)
   ===================================================================== */
@media (max-width: 768px){
    .topbar{ height: 64px; padding: 0 14px; }
    .main-content{ margin-top: 64px; padding: 14px; min-height: calc(100vh - 64px); }

    .card-body{ padding: 16px; }
    .card-header{ padding: 12px 16px; }

    .table thead th{ padding: 10px 12px; font-size: 10.5px; }
    .table td{ padding: 8px 11px; font-size: 12.5px; }

    .btn{ padding: 8px 14px; }
    .btn-sm{ padding: 5px 10px; font-size: 11px; }

    h3{ font-size: 1rem; }

    .modal-dialog{ margin: 10px; }
    .modal-body{ padding: 16px; }

    /* generic "title + action button" header used across pages */
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-3{
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-3 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > a.btn,
    .d-flex.justify-content-between.align-items-center.mb-3 > a.btn{
        width: 100%;
        text-align: center;
    }

    /* card headers that pair a title with action buttons */
    .card-header.d-flex.justify-content-between{
        flex-wrap: wrap;
        align-items: flex-start !important;
        gap: 10px;
    }
    .card-header.d-flex.justify-content-between > div:last-child{
        width: 100%;
    }
}


/* =====================================================================
   RESPONSIVE — PHONES (≤ 576px)
   ===================================================================== */
@media (max-width: 576px){
    .topbar{ padding: 0 12px; gap: 8px; }
    .topbar-left{ gap: 10px; }
    .topbar-left h5{ font-size: .95rem; max-width: 46vw; }
    .topbar-right{ gap: 6px; }

    .main-content{ padding: 12px; }

    .stat-card{ padding: 16px 16px; }
    .stat-number{ font-size: 1.6rem; }
    .stat-icon{ font-size: 1.8rem; right: 14px; }
    .stat-label{ font-size: 10px; letter-spacing: 1px; }

    .card-body{ padding: 14px; }
    .card-header{ padding: 11px 14px; font-size: 12px; }

    .table thead th{ padding: 9px 10px; font-size: 10px; }
    .table td{ padding: 8px 9px; font-size: 12px; }

    .btn-group-sm > .btn{ padding: 4px 8px; font-size: 10.5px; }

    h3{ font-size: .95rem; gap: 8px; }
    h3::before{ height: 16px; }

    .login-box{ padding: 32px 22px; }
}


/* =====================================================================
   RESPONSIVE — SMALL PHONES (≤ 420px)
   ===================================================================== */
@media (max-width: 420px){
    .topbar-username{ display: none; }
    .topbar-left h5{ max-width: 38vw; }

    .sidebar-logo{ font-size: 17px; padding: 16px; }

    .stat-number{ font-size: 1.4rem; }
    .stat-card{ padding: 14px; }

    .btn{ font-size: 11.5px; }
}


/* =====================================================================
   PRINT — hide chrome
   ===================================================================== */
@media print{
    .sidebar, .topbar, .sidebar-toggle, .sidebar-overlay{ display: none !important; }
    .main-content{ margin: 0 !important; padding: 0 !important; }
}
