/* ========================================
   MODERN DASHBOARD DESIGN - 2025
   Monitoring Kinerja Guru
   ======================================== */

/* ===== CSS VARIABLES ===== */
:root {
    --primary-color: #4e73df;
    --primary-dark: #224abe;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --topbar-height: 65px;

    --border-radius: 12px;
    --box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    --box-shadow-hover: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.25);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #4e73df 0%, #224abe 100%);
    z-index: 1040;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 0 2rem 0 rgba(0, 0, 0, 0.1);
    will-change: transform, width;
}

/* Ensure sidebar is always above content */
.sidebar * {
    pointer-events: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-height);
    padding: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-text {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    font-size: 1.8rem;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    list-style: none;
    margin: 0.25rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-link i {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 1rem 1.5rem;
}

.nav-heading {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 1.5rem;
    margin-top: 1rem;
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-brand-text span {
    display: none;
}

.sidebar.collapsed .nav-link span {
    display: none;
}

.sidebar.collapsed .nav-heading {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.85rem;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

/* Sidebar Transitions */
.sidebar {
    will-change: transform;
}

.sidebar.show {
    transform: translateX(0);
}

/* Improved mobile sidebar behavior */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 2rem 0 rgba(0, 0, 0, 0.15);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar.collapsed.show {
        transform: translateX(0);
    }
}

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid #e3e6f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    transition: var(--transition);
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.05);
}

/* Topbar mobile improvements */
@media (max-width: 768px) {
    .topbar {
        left: 0;
        padding: 0 1rem;
    }
}

/* Support for browsers without :has() selector */
.sidebar.collapsed ~ .main-content .topbar,
.sidebar.collapsed + .main-content .topbar {
    left: var(--sidebar-collapsed-width);
}

/* Fallback for browsers that support :has() */
@supports selector(:has(.sidebar)) {
    body:has(.sidebar.collapsed) .topbar {
        left: var(--sidebar-collapsed-width);
    }
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    outline: none;
}

.topbar-toggle:hover,
.topbar-toggle:focus {
    background: var(--light-color);
    color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(78, 115, 223, 0.1);
}

.topbar-toggle:active {
    transform: scale(0.95);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--light-color);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user:hover {
    background: #e2e6ea;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 2rem;
    min-height: calc(100vh - var(--topbar-height));
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

body:has(.sidebar.collapsed) .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--secondary-color);
    font-size: 0.95rem;
}

/* ===== CARDS ===== */
.card {
    background: white;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1.5rem;
    transition: var(--transition);
    overflow: hidden;
}

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

.card-header {
    background: white;
    border-bottom: 1px solid #e3e6f0;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Stats Cards */
.stat-card {
    background: white;
    border-left: 4px solid var(--primary-color);
    position: relative;
    overflow: visible;
}

.stat-card.stat-primary { border-left-color: var(--primary-color); }
.stat-card.stat-success { border-left-color: var(--success-color); }
.stat-card.stat-warning { border-left-color: var(--warning-color); }
.stat-card.stat-danger { border-left-color: var(--danger-color); }
.stat-card.stat-info { border-left-color: var(--info-color); }

.stat-card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
}

.stat-content h6 {
    color: var(--secondary-color);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-content h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
}

.stat-icon.icon-primary { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%); }
.stat-icon.icon-success { background: linear-gradient(135deg, var(--success-color) 0%, #17a673 100%); }
.stat-icon.icon-warning { background: linear-gradient(135deg, var(--warning-color) 0%, #dda20a 100%); }
.stat-icon.icon-danger { background: linear-gradient(135deg, var(--danger-color) 0%, #c33426 100%); }
.stat-icon.icon-info { background: linear-gradient(135deg, var(--info-color) 0%, #2c9faf 100%); }

/* Quick Action Cards */
.quick-action-card {
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.quick-action-card:hover {
    border-color: var(--primary-color);
    background: var(--light-color);
}

.quick-action-icon {
    width: 80px;
    height: 80px;
    margin: 1rem auto;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.quick-action-title {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.quick-action-desc {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* ===== BUTTONS ===== */
.btn {
    border-radius: 8px;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #17a673 100%);
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* ===== TABLES ===== */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--light-color);
    color: var(--dark-color);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #e3e6f0;
}

.table tbody tr:hover {
    background: var(--light-color);
}

/* ===== BADGES ===== */
.badge {
    padding: 0.5rem 0.875rem;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 1rem 1.25rem;
}

.alert-dismissible {
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== LOGIN PAGE ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 450px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
}

.login-header i {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.login-header h3 {
    margin: 0;
    font-weight: 700;
}

.login-body {
    padding: 2.5rem 2rem;
}

.form-floating {
    margin-bottom: 1.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 1050;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar.collapsed.show {
        transform: translateX(0);
    }

    .topbar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .user-info {
        display: none;
    }

    .stat-card-body {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .page-header {
        margin-bottom: 1.5rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .sidebar {
        width: 280px;
    }
}

/* ===== MOBILE OVERLAY ===== */
#sidebarOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

#sidebarOverlay.show {
    opacity: 1;
}

/* ===== UTILITIES ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Prevent body scroll when sidebar is open on mobile */
body.sidebar-open {
    overflow: hidden;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.shadow {
    box-shadow: var(--box-shadow) !important;
}

.shadow-lg {
    box-shadow: var(--box-shadow-hover) !important;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }
.fade-in-delay-4 { animation-delay: 0.4s; }
