/* ============================================================
   SRMP 8 CIMAHI - RESPONSIVE DESIGN SYSTEM
   Mobile-First, No Overflow, Ultra Clean
   ============================================================ */

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

/* ========================
   CSS VARIABLES
======================== */
:root {
    --primary:       #4f46e5;
    --primary-dark:  #3730a3;
    --success:       #059669;
    --info:          #0284c7;
    --warning:       #d97706;
    --danger:        #dc2626;

    --sidebar-w:     260px;
    --topbar-h:      64px;

    --bg:            #f1f5f9;
    --card-bg:       #ffffff;
    --text:          #1e293b;
    --muted:         #64748b;
    --border:        #e2e8f0;

    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --radius-xl:     20px;

    --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:     0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:     0 12px 28px rgba(0,0,0,.12);
}

/* ========================
   GLOBAL RESET & BASE
======================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    font-size: 16px; /* BASE FONT */
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 1rem;
}

/* ========================
   LAYOUT: SIDEBAR + CONTENT
======================== */
.sidebar-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* ========================
   SIDEBAR
======================== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: #fff;
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    padding: 20px 12px;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
    padding: 0 8px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.sidebar-brand a {
    font-size: .9rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li { margin-bottom: 4px; }

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    color: var(--muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .95rem;
    transition: all .2s;
    gap: 10px;
}

.sidebar-menu a i { width: 18px; font-size: .95rem; }

.sidebar-menu a:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.sidebar-menu a.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(79,70,229,.35);
}

.sidebar-menu a.active i { color: #fff; }

.sidebar-menu .dropdown-menu {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    margin: 4px 0 4px 20px;
    box-shadow: var(--shadow-md);
    list-style: none;
}

.sidebar-menu .dropdown-item {
    color: var(--muted);
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    transition: all .2s;
    display: block;
}

.sidebar-menu .dropdown-item:hover,
.sidebar-menu .dropdown-item.active {
    background: rgba(79,70,229,.08);
    color: var(--primary);
    font-weight: 600;
}

/* ========================
   MOBILE TOGGLE & OVERLAY
======================== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    width: 42px;
    height: 42px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(79,70,229,.4);
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: transform .2s;
}

.sidebar-toggle:active { transform: scale(.93); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(3px);
    z-index: 1040;
}

.sidebar-overlay.active { display: block; }

/* ========================
   MAIN CONTENT
======================== */
.main-content {
    flex: 1;
    min-width: 0;                 /* KUNCI: cegah flex child overflow */
    margin-left: var(--sidebar-w);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ========================
   TOP HEADER (PROFILE BADGE)
======================== */
.top-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 6px 12px 6px 6px;
    max-width: calc(100vw - 80px);   /* KUNCI: tidak melebihi layar HP */
    min-width: 0;
}

.user-avatar {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    flex-shrink: 0 !important;
    font-size: .9rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: #fff !important;
    border-radius: 50% !important;
}

.user-info-text {
    min-width: 0;
    overflow: hidden;
}

.user-info-text .fw-bold {
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.user-info-text small {
    font-size: .72rem;
    color: var(--muted);
    display: block;
}

.btn-logout-link {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #fca5a5;
    color: var(--danger);
    border-radius: 50px;
    padding: 5px 12px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    transition: all .2s;
}

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

/* ========================
   PAGE CONTENT (INNER)
======================== */
.page-content {
    padding: 20px;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    width: 100%;
}

/* ========================
   CARDS
======================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    transition: box-shadow .2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
    padding: 16px 22px;
    border-bottom: none;
    font-size: 1.05rem;
}

.card-header.bg-success { background: linear-gradient(135deg, #059669, #047857) !important; }
.card-header.bg-info    { background: linear-gradient(135deg, #0284c7, #0369a1) !important; }
.card-header.bg-warning { background: linear-gradient(135deg, #d97706, #b45309) !important; color: #fff !important; }
.card-header.bg-danger  { background: linear-gradient(135deg, #dc2626, #b91c1c) !important; }

.card-body { padding: 20px; }

/* Stat Cards (Dashboard) */
.card-stat {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-md) !important;
}

.card-stat-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8) !important; }
.card-stat-success { background: linear-gradient(135deg, #059669, #047857) !important; }
.card-stat-info    { background: linear-gradient(135deg, #0284c7, #0369a1) !important; }

.btn-stat-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: rgba(255,255,255,.95);
    color: #1e293b;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-weight: 700;
    font-size: .875rem;
    text-decoration: none;
    margin-top: 14px;
    transition: all .2s;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.btn-stat-action:hover {
    background: #fff;
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ========================
   BUTTONS
======================== */
.btn {
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-weight: 600;
    font-size: .95rem;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all .2s;
    cursor: pointer;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-success   { background: linear-gradient(135deg, #059669, #047857); color: #fff; }
.btn-info      { background: linear-gradient(135deg, #0284c7, #0369a1); color: #fff; }
.btn-warning   { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.btn-danger    { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-light     { background: #f1f5f9; color: var(--text); }

.btn-outline-danger {
    background: transparent;
    border: 1.5px solid #fca5a5;
    color: var(--danger);
}

.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-info { background: transparent; border: 1.5px solid #0284c7; color: #0284c7; }
.btn-outline-info:hover { background: #0284c7; color: #fff; }

.btn-sm { padding: 7px 14px; font-size: .875rem; border-radius: var(--radius-sm); }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn-group .btn { border-radius: var(--radius-sm) !important; }

/* ========================
   FORMS
======================== */
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 11px 15px;
    font-size: .95rem;
    background: #f8fafc;
    color: var(--text);
    transition: all .2s;
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    background: #fff;
    outline: none;
}

.form-label {
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    font-size: .95rem;
    display: block;
}

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }

.btn-eye-toggle {
    background: #fff !important;
    border: 1.5px solid var(--border) !important;
    border-left: none !important;
    color: var(--muted) !important;
    padding: 0 14px !important;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-radius: 0 var(--radius-md) var(--radius-md) 0 !important;
    transition: all .2s;
    z-index: 5;
}

.btn-eye-toggle:hover { color: var(--text) !important; }

/* ========================
   TABLES
======================== */
.table-responsive {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: #fff;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    width: 100%;
}

.table { width: 100%; margin: 0; border-collapse: collapse; }

.table thead th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    font-size: .95rem;
    border-bottom: 1px solid var(--border);
}

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

/* ========================
   BADGES & ALERTS
======================== */
.badge { border-radius: 50px; font-weight: 600; padding: 5px 13px; font-size: .8rem; }

.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 14px 18px;
    font-weight: 500;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #e0f2fe; color: #0c4a6e; }
.alert-warning { background: #fef9c3; color: #854d0e; }

/* ========================
   MODALS
======================== */
.modal-content {
    border-radius: var(--radius-xl);
    border: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ========================
   HEADINGS
======================== */
h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: .95rem; }
h6 { font-size: .875rem; }

/* ========================
   PRINT STYLES
======================== */
@media print {
    .sidebar, .sidebar-toggle, .sidebar-overlay, .top-header, footer, .btn-group, .no-print { display: none !important; }
    body { background: #fff !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}

/* ========================
   RESPONSIVE: TABLET <= 992px
======================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .top-header {
        padding-left: 64px; /* beri jarak dari tombol hamburger */
    }
}

/* ========================
   RESPONSIVE: MOBILE <= 768px
======================== */
@media (max-width: 768px) {
    .page-content { padding: 14px 12px; }

    .card-body { padding: 16px; }
    .card-header { padding: 14px 16px; font-size: .9rem; }

    .btn-group {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        width: 100%;
    }

    .btn-group .btn {
        flex: 1 1 auto !important;
    }

    /* Sembunyikan teks logout di HP, cukup ikon */
    .btn-logout-text { display: none; }

    .modal-dialog { margin: 10px; }
}

/* ========================
   RESPONSIVE: SMALL PHONE <= 480px
======================== */
@media (max-width: 480px) {
    .user-info-text small { display: none; }

    .page-content { padding: 12px 10px; }

    h2 { font-size: 1.2rem; }

    .top-header { padding: 10px 12px; padding-left: 64px; }
}
