/* style.css - Unified Design System for SIMS */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #e2e8f0;
    --secondary-hover: #cbd5e1;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-width: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-bright: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-dark);
    min-height: 100vh;
}

/* ============================================================
   Typography & Badges
   ============================================================ */
h1, h2, h3, h4 {
    color: var(--text-dark);
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.badge-regular   { background-color: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-proxy     { background-color: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-free      { background-color: #dcfce7; color: #166534; }
.badge-active    { background-color: var(--success-bg); color: var(--success-text); border: 1px solid #86efac; }
.badge-inactive  { background-color: #f1f5f9; color: var(--text-muted); }
.badge-count     { background-color: #f1f5f9; color: var(--text-muted); padding: 2px 7px; border-radius: 12px; font-weight: 600; }
.badge-code      { background-color: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; font-weight: 700; }

/* ============================================================
   Layout: Navbar, Wrapper & Containers
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.hamburger-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #334155;
    display: flex;
    align-items: center;
}

.page-title {
    font-size: 16px;
    font-weight: 700;
}

.container {
    padding: 16px;
    max-width: 1250px;
    margin: 0 auto;
}

/* ============================================================
   Cards & Grids
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 18px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crud-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .crud-layout {
        grid-template-columns: 360px 1fr;
        align-items: start;
    }
}

/* ============================================================
   Form Controls & Buttons
   ============================================================ */
.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-cancel    { background: var(--secondary); color: #334155; }
.btn-cancel:hover { background: var(--secondary-hover); }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}
.btn-edit   { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }
.btn-delete { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecdd3; }

/* ============================================================
   Tables & Search
   ============================================================ */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th, td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.search-box {
    margin-bottom: 14px;
    position: relative;
}

.search-box input {
    padding-left: 34px;
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 10px;
    top: 10px;
    font-size: 13px;
    opacity: 0.6;
}

/* ============================================================
   Alert Notices
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bbf7d0; }
.alert-error   { background: var(--danger-bg); color: var(--danger-text); border: 1px solid #fecdd3; }

/* ============================================================
   Mobile Responsiveness
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .sidebar-close-btn { display: block; }
    .main-wrapper { margin-left: 0; }
}

/* ============================================================
   Dashboard Specific Components (index.php)
   ============================================================ */
.welcome-card {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.25);
}

.welcome-card h2 {
    font-size: 22px;
    margin-bottom: 4px;
    font-weight: 700;
    color: #ffffff;
}

.welcome-card p {
    font-size: 13px;
    opacity: 0.9;
    color: #e0e7ff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-num {
    font-size: 24px;
    font-weight: 700;
    color: #2563eb;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    margin-top: 2px;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 600px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.menu-card {
    background: white;
    border-radius: 14px;
    padding: 18px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.menu-card:hover {
    border-color: #2563eb;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
    transform: translateY(-2px);
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.icon-absent  { background: #fef2f2; color: #dc2626; }
.icon-arrange { background: #eff6ff; color: #2563eb; }
.icon-report  { background: #f0fdf4; color: #16a34a; }
.icon-master  { background: #fdf4ff; color: #a855f7; }

.menu-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 2px;
}

.menu-info p {
    font-size: 12px;
    color: #64748b;
}

/* Sidebar Layout & Toggle Styles */
.sidebar {
    width: var(--sidebar-width, 250px);
    height: 100vh;
    background: #0f172a;
    color: #94a3b8;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, margin-left 0.25s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.school-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.school-avatar {
    width: 38px;
    height: 38px;
    background: #2563eb;
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.school-info {
    overflow: hidden;
}

.school-name {
    color: white;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.school-role {
    font-size: 11px;
    color: #64748b;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
}

.sidebar-menu {
    padding: 14px 10px;
    overflow-y: auto;
    flex: 1;
}

.menu-heading {
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.8px;
    margin: 14px 8px 6px 8px;
}

.nav-list {
    list-style: none;
    margin-bottom: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: #1e293b;
    color: white;
}

.nav-link.active {
    background: #2563eb;
    color: white;
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
}

/* Desktop Collapse Handling */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}
body.sidebar-collapsed .main-wrapper {
    margin-left: 0 !important;
}

/* Mobile Responsive Drawer */
@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .sidebar-close-btn {
        display: block;
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
}

/* Custom Sleek Scrollbar for Sidebar */
.sidebar-menu {
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Chrome, Edge, Safari, Opera */
.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}