/* ============================================================
   eRaporSD - Main Stylesheet
   ============================================================ */

/* Variables */
:root {
    --primary:        #1e88e5;
    --primary-dark:   #1565c0;
    --primary-light:  #e3f2fd;
    --secondary:      #43a047;
    --secondary-dark: #2e7d32;
    --danger:         #e53935;
    --warning:        #ff8f00;
    --info:           #0288d1;
    --dark:           #263238;
    --gray:           #607d8b;
    --light:          #f5f6fa;
    --sidebar-w:      250px;
    --navbar-h:       60px;
    --shadow:         0 2px 12px rgba(0,0,0,.08);
    --radius:         8px;
    --transition:     .25s ease;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Geneva, sans-serif; font-size: 14px; color: #333; background: var(--light); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
.text-muted { color: var(--gray) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1565c0 0%, #1e88e5 50%, #42a5f5 100%);
}
.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }
.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    padding: 40px 36px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 { font-size: 1.8rem; color: var(--dark); font-weight: 700; }
.login-header p { color: var(--gray); font-size: .95rem; margin-top: 4px; }
.login-header img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 12px; }
.login-footer { text-align: center; margin-top: 20px; color: var(--gray); }

/* Form */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: #444; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fafafa;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,136,229,.15);
    background: #fff;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.input-password { position: relative; }
.input-password .form-control { padding-right: 42px; }
.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--gray);
}
.toggle-password:hover { color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-secondary { background: var(--gray);       color: #fff; }
.btn-success   { background: var(--secondary);  color: #fff; }
.btn-danger    { background: var(--danger);     color: #fff; }
.btn-warning   { background: var(--warning);    color: #fff; }
.btn-info      { background: var(--info);       color: #fff; }
.btn-outline-primary   { background: transparent; color: var(--primary);   border: 2px solid var(--primary); }
.btn-outline-secondary { background: transparent; color: var(--gray);       border: 2px solid var(--gray); }
.btn-outline-danger    { background: transparent; color: var(--danger);     border: 2px solid var(--danger); }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-icon { padding: 6px 10px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .93rem;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--secondary); }
.alert-danger  { background: #ffebee; color: #c62828; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff8e1; color: #e65100; border-left: 4px solid var(--warning); }
.alert-info    { background: #e1f5fe; color: #01579b; border-left: 4px solid var(--info); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-h);
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    margin-right: auto;
}
.navbar-brand i { font-size: 1.4rem; }
.navbar-toggler {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 16px;
    font-size: 1.1rem;
    transition: background var(--transition);
}
.navbar-toggler:hover { background: rgba(255,255,255,.25); }
.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.9);
    cursor: pointer;
    position: relative;
}
.navbar-user img, .navbar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.5);
}
.navbar-user .avatar {
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}
.navbar-user-info { display: flex; flex-direction: column; }
.navbar-user-info .name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.navbar-user-info .role { font-size: .75rem; opacity: .8; text-transform: capitalize; }
.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    min-width: 200px;
    z-index: 1001;
    display: none;
    overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #444;
    font-size: .9rem;
    transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--primary-light); color: var(--primary); }
.user-dropdown hr { margin: 4px 0; border: none; border-top: 1px solid #eee; }
.user-dropdown .text-danger:hover { background: #ffebee; color: var(--danger); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    width: var(--sidebar-w);
    bottom: 0;
    background: var(--dark);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 900;
    transition: width var(--transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar.collapsed { width: 60px; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.sidebar-menu { list-style: none; padding: 12px 0; }
.sidebar-menu-title {
    padding: 8px 20px 4px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.4);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-menu-title { opacity: 0; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,.75);
    font-size: .9rem;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    border-left: 3px solid transparent;
}
.sidebar-menu li a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: var(--primary);
}
.sidebar-menu li a.active {
    background: rgba(30,136,229,.2);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-menu li a i {
    font-size: 1.05rem;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-menu li a .menu-text { transition: opacity var(--transition); }
.sidebar.collapsed .menu-text { opacity: 0; width: 0; overflow: hidden; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--navbar-h);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-h));
    transition: margin-left var(--transition);
}
.main-content.expanded { margin-left: 60px; }

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 { font-size: 1.4rem; color: var(--dark); display: flex; align-items: center; gap: 10px; }
.page-header h2 i { color: var(--primary); }

/* Cards */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    border: none;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h5, .card-header h4 { margin: 0; font-weight: 600; color: var(--dark); }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid #eee; background: #fafafa; }

/* Stat Cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
    margin-bottom: 20px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}
.stat-icon.blue   { background: linear-gradient(135deg, var(--primary), #64b5f6); }
.stat-icon.green  { background: linear-gradient(135deg, var(--secondary), #81c784); }
.stat-icon.orange { background: linear-gradient(135deg, var(--warning), #ffcc02); }
.stat-icon.red    { background: linear-gradient(135deg, var(--danger), #ef9a9a); }
.stat-info .value { font-size: 1.8rem; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-info .label { color: var(--gray); font-size: .85rem; margin-top: 4px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-responsive { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    background: var(--primary);
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--primary-light); }
.table-striped tr:nth-child(even) td { background: #f8f9fa; }
.table-striped tr:nth-child(even):hover td { background: var(--primary-light); }

/* Avatar in table */
.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e0e0e0;
}
.avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
}

/* Badge / Status */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-success { background: #e8f5e9; color: var(--secondary-dark); }
.badge-danger  { background: #ffebee; color: #c62828; }
.badge-warning { background: #fff8e1; color: #e65100; }
.badge-info    { background: #e1f5fe; color: #01579b; }
.badge-secondary { background: #eceff1; color: var(--gray); }

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}
.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid #e0e0e0;
    background: #fff;
    transition: all var(--transition);
}
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled span { color: #ccc; cursor: not-allowed; }

/* ============================================================
   GRID (Simple Bootstrap-like)
   ============================================================ */
.row { display: flex; flex-wrap: wrap; margin: -10px; }
.row > * { padding: 10px; }
.col-12 { width: 100%; }
.col-md-3  { width: 25%; }
.col-md-4  { width: 33.333%; }
.col-md-5  { width: 41.666%; }
.col-md-6  { width: 50%; }
.col-md-7  { width: 58.333%; }
.col-md-8  { width: 66.666%; }
.col-md-9  { width: 75%; }
.col-md-12 { width: 100%; }

/* Filter bar */
.filter-bar {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.filter-bar label { font-size: .85rem; font-weight: 600; color: #555; margin-bottom: 4px; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: .9rem; width: 100%; }

/* Foto preview */
.foto-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
    display: block;
    margin: 8px auto;
}
.foto-preview-rect {
    width: 120px;
    height: 80px;
    object-fit: contain;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    display: block;
    margin: 8px 0;
}

/* Modal konfirmasi hapus */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    text-align: center;
}
.modal-box .modal-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-box h4 { margin-bottom: 8px; }
.modal-box p { color: var(--gray); margin-bottom: 20px; }
.modal-buttons { display: flex; gap: 10px; justify-content: center; }

/* ============================================================
   RAPOR PRINT STYLE
   ============================================================ */
.rapor-container {
    max-width: 210mm;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    font-family: 'Times New Roman', Times, serif;
    font-size: 11pt;
    line-height: 1.5;
}
.rapor-header { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
.rapor-header img { width: 70px; height: 70px; object-fit: contain; }
.rapor-header .sekolah-info { text-align: center; flex: 1; }
.rapor-header .sekolah-info .nama { font-size: 14pt; font-weight: bold; text-transform: uppercase; }
.rapor-header .sekolah-info .alamat { font-size: 10pt; }
.rapor-title { text-align: center; font-size: 13pt; font-weight: bold; text-transform: uppercase; margin: 10px 0; letter-spacing: 2px; }
.rapor-identitas table { width: 100%; font-size: 10pt; }
.rapor-identitas td { padding: 2px 4px; }
.rapor-identitas td:first-child { width: 120px; }
.rapor-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 10pt; }
.rapor-table th, .rapor-table td { border: 1px solid #000; padding: 5px 8px; }
.rapor-table th { background: #f0f0f0; text-align: center; font-weight: bold; }
.rapor-table td { vertical-align: top; }
.rapor-table .no { text-align: center; }
.rapor-table .nilai { text-align: center; font-weight: bold; }
.ttd-section { display: flex; justify-content: space-between; margin-top: 20px; font-size: 10pt; }
.ttd-box { text-align: center; }
.ttd-box .ttd-line { border-bottom: 1px solid #000; width: 150px; margin: 50px auto 4px; }
.ttd-box .ttd-name { font-weight: bold; }
.ttd-box .ttd-nip { font-size: 9pt; }

.rapor-print-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 500;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; padding: 16px; }
    .col-md-3, .col-md-4, .col-md-5, .col-md-6,
    .col-md-7, .col-md-8, .col-md-9 { width: 100%; }
    .navbar-user-info { display: none; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stat-card { padding: 14px; }
    .stat-info .value { font-size: 1.4rem; }
    .filter-bar { flex-direction: column; }
}

/* ============================================================
   PRINT GLOBAL
   ============================================================ */
@media print {
    .navbar, .sidebar, .page-header .btn, .rapor-print-btn,
    .filter-bar, .btn, .pagination, .card-footer { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
    .rapor-container { padding: 0 !important; max-width: 100% !important; }
    .card { box-shadow: none !important; }
    @page { size: A4 portrait; margin: 15mm 15mm 15mm 20mm; }
}

/* Utilities */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.ms-auto { margin-left: auto; }
.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }
.text-small { font-size: .82rem; }
.required { color: var(--danger); }
.form-text { font-size: .82rem; color: var(--gray); margin-top: 4px; }
.divider { border: none; border-top: 1px solid #eee; margin: 16px 0; }
