/* ============================================================
   GNMS - National Grama Niladhari Management System
   Custom Stylesheet
   ============================================================ */

:root {
    --gnms-primary: #1a3c6e;
    --gnms-secondary: #c8a84b;
    --gnms-accent: #2e7d32;
    --gnms-light: #f0f4f8;
    --gnms-dark: #0d2137;
    --gnms-text: #2c3e50;
    --sidebar-width: 260px;
    --sidebar-bg: #0d2137;
    --topbar-height: 60px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--gnms-light);
    color: var(--gnms-text);
    font-size: 14px;
}

/* ---- SIDEBAR ---- */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

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

.sidebar-brand {
    padding: 16px 20px;
    background: var(--gnms-primary);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand .brand-logo {
    width: 36px; height: 36px;
    background: var(--gnms-secondary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800;
    color: var(--gnms-dark);
    flex-shrink: 0;
}

.sidebar-brand .brand-text h6 {
    color: #fff; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; margin: 0;
}
.sidebar-brand .brand-text small { color: var(--gnms-secondary); font-size: 9px; }

.sidebar-section {
    padding: 12px 20px 6px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(255,255,255,.4);
}

.nav-item .nav-link {
    color: rgba(255,255,255,.7) !important;
    padding: 10px 20px;
    border-radius: 0;
    font-size: 13px;
    display: flex; align-items: center; gap: 10px;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.nav-item .nav-link:hover,
.nav-item .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,.08);
    border-left-color: var(--gnms-secondary);
}

.nav-item .nav-link i {
    width: 18px; text-align: center;
    color: rgba(255,255,255,.5);
}
.nav-item .nav-link:hover i,
.nav-item .nav-link.active i { color: var(--gnms-secondary); }

.nav-item .nav-link .badge-count {
    margin-left: auto;
    background: var(--gnms-secondary);
    color: var(--gnms-dark);
    font-size: 10px; font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

/* Sub-menu */
.sidebar-submenu { padding-left: 0; list-style: none; margin: 0; }
.sidebar-submenu .nav-link {
    padding-left: 52px !important;
    font-size: 12px !important;
    border-left-color: transparent !important;
}
.sidebar-submenu .nav-link::before {
    content: '›';
    position: absolute;
    left: 38px;
    color: rgba(255,255,255,.4);
}

/* ---- MAIN CONTENT ---- */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin .3s;
}

/* ---- TOPBAR ---- */
#topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8edf2;
    position: sticky; top: 0; z-index: 900;
    padding: 0 24px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-search {
    flex: 1; max-width: 360px;
}
.topbar-search .form-control {
    border-radius: 20px;
    border: 1px solid #e8edf2;
    background: #f8fafc;
    font-size: 13px;
    padding: 6px 16px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px solid #e8edf2;
    display: flex; align-items: center; justify-content: center;
    color: #6c757d; cursor: pointer;
    position: relative; transition: all .2s;
}
.topbar-btn:hover { background: var(--gnms-light); color: var(--gnms-primary); }
.topbar-btn .notification-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: #dc3545; border-radius: 50%;
    border: 2px solid #fff;
}

.user-menu { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 20px; }
.user-menu:hover { background: var(--gnms-light); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--gnms-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
}

/* ---- PAGE HEADER ---- */
.page-header {
    padding: 20px 24px 0;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    flex-wrap: wrap;
}
.page-header h1 {
    font-size: 22px; font-weight: 700;
    color: var(--gnms-primary); margin: 0;
}
.page-header .breadcrumb {
    font-size: 12px; margin: 4px 0 0;
}
.page-header .breadcrumb .breadcrumb-item a { color: var(--gnms-primary); text-decoration: none; }

/* ---- STAT CARDS ---- */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e8edf2;
    transition: transform .2s, box-shadow .2s;
    height: 100%;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.08); }

.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--gnms-primary); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: #6c757d; margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-change {
    font-size: 11px; margin-top: 8px;
    display: flex; align-items: center; gap: 4px;
}
.stat-card .stat-change.up { color: #2e7d32; }
.stat-card .stat-change.down { color: #c62828; }

/* ---- DATA TABLE CARD ---- */
.data-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8edf2;
    overflow: hidden;
}
.data-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f4f8;
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.data-card-header h5 { font-size: 15px; font-weight: 700; color: var(--gnms-primary); margin: 0; }
.data-card-body { padding: 0; }

/* ---- TABLE ---- */
.gnms-table { width: 100%; border-collapse: collapse; }
.gnms-table th {
    background: #f8fafc;
    padding: 10px 16px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: #6c757d;
    border-bottom: 1px solid #e8edf2;
    white-space: nowrap;
}
.gnms-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f5f7fa;
    font-size: 13px; vertical-align: middle;
}
.gnms-table tr:last-child td { border-bottom: none; }
.gnms-table tbody tr:hover { background: #f8fafc; }

/* ---- FORMS ---- */
.form-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8edf2;
    margin-bottom: 20px;
}
.form-section-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f4f8;
    font-size: 13px; font-weight: 700;
    color: var(--gnms-primary);
    display: flex; align-items: center; gap: 8px;
}
.form-section-body { padding: 20px; }

.form-label { font-size: 12px; font-weight: 600; color: #4a5568; text-transform: uppercase; letter-spacing: .3px; }
.form-control, .form-select {
    font-size: 13px;
    border-color: #d9e1ec;
    border-radius: 8px;
    padding: 8px 12px;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--gnms-primary);
    box-shadow: 0 0 0 3px rgba(26,60,110,.1);
}
.form-control.is-invalid { border-color: #dc3545; }
.invalid-feedback { font-size: 11px; }

/* ---- BUTTONS ---- */
.btn-gnms-primary {
    background: var(--gnms-primary);
    border-color: var(--gnms-primary);
    color: #fff;
    font-size: 13px; font-weight: 600;
    padding: 8px 20px;
    border-radius: 8px;
    transition: all .2s;
}
.btn-gnms-primary:hover { background: var(--gnms-dark); border-color: var(--gnms-dark); color: #fff; }

.btn-gnms-secondary {
    background: var(--gnms-secondary);
    border-color: var(--gnms-secondary);
    color: var(--gnms-dark);
    font-size: 13px; font-weight: 700;
}
.btn-gnms-secondary:hover { filter: brightness(.9); color: var(--gnms-dark); }

.btn-sm { padding: 4px 12px; font-size: 12px; border-radius: 6px; }

/* ---- BADGE ---- */
.badge { font-size: 10px; font-weight: 600; padding: 4px 8px; border-radius: 4px; }

/* ---- STATUS TIMELINE ---- */
.status-timeline { position: relative; padding-left: 24px; }
.status-timeline::before {
    content: ''; position: absolute;
    left: 8px; top: 8px; bottom: 8px;
    width: 2px; background: #e8edf2;
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before {
    content: ''; position: absolute;
    left: -20px; top: 4px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--gnms-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--gnms-primary);
}
.timeline-item .timeline-time { font-size: 11px; color: #6c757d; }
.timeline-item .timeline-text { font-size: 13px; }

/* ---- PROFILE CARD ---- */
.profile-card {
    background: linear-gradient(135deg, var(--gnms-primary), var(--gnms-dark));
    border-radius: 12px; color: #fff;
    padding: 24px; text-align: center;
}
.profile-card .avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800; border: 3px solid var(--gnms-secondary);
}
.profile-card .profile-name { font-size: 16px; font-weight: 700; }
.profile-card .profile-role { font-size: 11px; color: var(--gnms-secondary); text-transform: uppercase; letter-spacing: 1px; }
.profile-card .profile-gn { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 4px; }

/* ---- QR CERTIFICATE CARD ---- */
.cert-card {
    border: 2px solid var(--gnms-primary);
    border-radius: 12px;
    overflow: hidden;
}
.cert-header {
    background: var(--gnms-primary);
    color: #fff; padding: 16px 20px;
    display: flex; align-items: center; gap: 12px;
}
.cert-header .seal {
    width: 48px; height: 48px;
    border: 2px solid var(--gnms-secondary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--gnms-secondary);
}
.cert-body { padding: 20px; }
.cert-field { margin-bottom: 10px; }
.cert-field .cf-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #6c757d; }
.cert-field .cf-value { font-size: 14px; font-weight: 600; color: var(--gnms-primary); }
.cert-footer {
    background: #f8fafc;
    padding: 12px 20px;
    border-top: 1px dashed #cdd;
    display: flex; justify-content: space-between; align-items: center;
}

/* ---- MAP ---- */
#gnms-map { height: 500px; border-radius: 12px; overflow: hidden; border: 1px solid #e8edf2; }

/* ---- CHARTS ---- */
.chart-container { position: relative; height: 280px; }

/* ---- ALERTS ---- */
.alert { border-radius: 10px; font-size: 13px; border: none; }
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-danger  { background: #ffebee; color: #c62828; }
.alert-warning { background: #fff8e1; color: #e65100; }
.alert-info    { background: #e3f2fd; color: #1565c0; }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--gnms-dark) 0%, var(--gnms-primary) 60%, #1e5799 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    width: 100%; max-width: 440px;
    box-shadow: 0 24px 64px rgba(0,0,0,.3);
    overflow: hidden;
}
.login-header {
    background: var(--gnms-primary);
    padding: 28px 32px;
    text-align: center;
}
.login-logo {
    width: 64px; height: 64px;
    background: var(--gnms-secondary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 900;
    color: var(--gnms-dark);
    margin: 0 auto 12px;
}
.login-header h4 { color: #fff; font-size: 16px; font-weight: 700; margin: 0; }
.login-header p  { color: var(--gnms-secondary); font-size: 11px; margin: 4px 0 0; letter-spacing: 1px; }
.login-body { padding: 28px 32px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    .page-header h1 { font-size: 18px; }
}

/* ---- UTILITY ---- */
.content-wrapper { padding: 20px 24px 40px; }
.gap-12 { gap: 12px; }
.text-gnms { color: var(--gnms-primary); }
.bg-gnms  { background: var(--gnms-primary); }
.border-gnms { border-color: var(--gnms-primary) !important; }
.fw-700 { font-weight: 700; }
.fs-11  { font-size: 11px; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }

.hover-lift { transition: transform .2s, box-shadow .2s; }
.hover-lift:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }

/* ---- PRINT ---- */
@media print {
    #sidebar, #topbar, .no-print { display: none !important; }
    #main-content { margin: 0; }
    .cert-card { border: 2px solid #000; page-break-inside: avoid; }
}
