/* =============================================
   ITI MIS - Main Stylesheet
   ============================================= */

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

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #0f766e;
    --accent: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --info: #0891b2;

    --bg: #f0f4f8;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #334155;
    --sidebar-active: #1e40af;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 4px 16px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Plus Jakarta Sans', sans-serif;
    --font-heading: 'Sora', sans-serif;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* =============================================
   LAYOUT
   ============================================= */
.wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width .3s;
    overflow: hidden;
}

.sidebar-brand {
    padding: 20px 16px;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    width: 38px; height: 38px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: white; font-weight: 800;
    font-family: var(--font-heading);
    flex-shrink: 0;
}

.sidebar-brand .brand-text { color: white; }
.sidebar-brand .brand-text h2 { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-brand .brand-text span { font-size: 11px; color: #94a3b8; }

.sidebar-user {
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
    display: flex; align-items: center; gap: 10px;
}

.sidebar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 14px;
    flex-shrink: 0; overflow: hidden;
}

.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .user-info h4 { font-size: 12px; color: white; font-weight: 600; }
.sidebar-user .user-info span { font-size: 11px; color: #94a3b8; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }

.nav-section-title {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    font-size: 13px; font-weight: 500;
    transition: all .2s;
    cursor: pointer; border-radius: 0;
    position: relative;
}

.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 20px;
    font-weight: 700;
}

.nav-item.logout { color: #f87171; margin-top: auto; }
.nav-item.logout:hover { background: #450a0a; color: #fca5a5; }

.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex; align-items: center;
    position: sticky; top: 0; z-index: 50;
    gap: 12px;
}

.topbar-title { font-family: var(--font-heading); font-size: 18px; font-weight: 700; flex: 1; }
.topbar-title span { font-size: 12px; font-weight: 400; color: var(--text-muted); display: block; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 8px; border: 1px solid var(--border);
    background: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; transition: all .2s;
}
.topbar-btn:hover { background: var(--bg); }

.page-content { padding: 24px; flex: 1; }

/* =============================================
   STAT CARDS
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform .2s, box-shadow .2s;
}

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

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; }
.stat-icon.green  { background: #f0fdf4; }
.stat-icon.yellow { background: #fffbeb; }
.stat-icon.red    { background: #fef2f2; }
.stat-icon.teal   { background: #f0fdfa; }
.stat-icon.purple { background: #faf5ff; }

.stat-info h3 { font-size: 26px; font-weight: 800; font-family: var(--font-heading); line-height: 1; }
.stat-info p  { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.stat-more    { font-size: 11px; color: var(--primary); font-weight: 600; cursor: pointer; margin-top: 4px; display: block; }

/* =============================================
   CARDS & TABLES
   ============================================= */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}

.card-title { font-size: 15px; font-weight: 700; font-family: var(--font-heading); }
.card-subtitle { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbfc; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-family: var(--font);
    font-size: 13px; font-weight: 600;
    transition: all .2s; text-decoration: none;
}

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning   { background: var(--warning); color: white; }
.btn-info      { background: var(--info); color: white; }
.btn-secondary { background: #64748b; color: white; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 7px 9px; }

/* =============================================
   FORMS
   ============================================= */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: white;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

textarea { resize: vertical; min-height: 90px; }

.form-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 6px;
}

/* =============================================
   BADGES & STATUS
   ============================================= */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-primary  { background: #dbeafe; color: #1d4ed8; }
.badge-secondary{ background: #f1f5f9; color: #475569; }

/* =============================================
   SEARCH & FILTER BAR
   ============================================= */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.search-input {
    position: relative; flex: 1; min-width: 200px;
}
.search-input input { padding-left: 36px; }
.search-input::before {
    content: '🔍'; position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%); font-size: 13px;
}

/* =============================================
   ATTENDANCE SPECIFIC
   ============================================= */
.attendance-status {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 700;
}
.att-p { background: #dcfce7; color: #15803d; }
.att-a { background: #fee2e2; color: #b91c1c; }
.att-l { background: #fef3c7; color: #b45309; }

.att-toggle {
    display: flex; gap: 0;
    border: 1.5px solid var(--border);
    border-radius: 8px; overflow: hidden;
}
.att-toggle label {
    padding: 5px 12px; cursor: pointer;
    font-size: 12px; font-weight: 600;
    margin: 0; text-transform: none;
    letter-spacing: 0;
    transition: all .15s;
    color: var(--text-muted);
}
.att-toggle input[type="radio"] { display: none; }
.att-toggle input[type="radio"]:checked + label.p-label { background: #dcfce7; color: #15803d; }
.att-toggle input[type="radio"]:checked + label.a-label { background: #fee2e2; color: #b91c1c; }
.att-toggle input[type="radio"]:checked + label.l-label { background: #fef3c7; color: #b45309; }

/* =============================================
   CHAT / COMPLAINT BOX
   ============================================= */
.chat-box {
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 380px;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}

.chat-msg { display: flex; gap: 10px; align-items: flex-end; }
.chat-msg.sent { flex-direction: row-reverse; }

.chat-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px; line-height: 1.5;
}

.chat-msg.received .chat-bubble {
    background: white;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-msg.sent .chat-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-meta { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.chat-input-bar { display: flex; gap: 8px; margin-top: 10px; }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #1e3a8a 100%);
    position: relative; overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.4);
    position: relative; z-index: 1;
}

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

.login-logo .logo-icon {
    width: 64px; height: 64px;
    background: var(--primary);
    border-radius: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px; color: white; font-weight: 900;
    font-family: var(--font-heading);
    margin-bottom: 12px;
    box-shadow: 0 8px 20px rgba(30,64,175,.4);
}

.login-logo h1 { font-family: var(--font-heading); font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.role-tabs {
    display: flex; gap: 0;
    background: #f1f5f9;
    border-radius: 10px; padding: 4px;
    margin-bottom: 24px;
}

.role-tab {
    flex: 1; padding: 8px 4px;
    text-align: center; border-radius: 8px;
    font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all .2s;
    color: var(--text-muted);
}
.role-tab.active { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }

.login-btn {
    width: 100%; padding: 12px;
    background: var(--primary); color: white;
    border: none; border-radius: 10px;
    font-family: var(--font);
    font-size: 15px; font-weight: 700;
    cursor: pointer; margin-top: 8px;
    transition: all .2s;
}
.login-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .sidebar { width: 0; }
    .main-content { margin-left: 0; }
    .sidebar.open { width: 240px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* =============================================
   MISC UTILITIES
   ============================================= */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.no-data { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-family: var(--font-heading); font-size: 22px; font-weight: 700; }
.page-header p  { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800;
    font-family: var(--font-heading);
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.info-item label { margin-bottom: 2px; }
.info-item .value { font-size: 14px; font-weight: 500; }
