/* 
 * MBG Administration Style System
 * Theme: Modern Navy Blue (BGN Branding), Glassmorphism, Clean
 */

:root {
    /* Color Palette - BGN Navy Blue Theme */
    --primary-color: #0d3b66;
    --primary-light: #1a5490;
    --primary-dark: #0a2647;
    --accent-color: #f4d35e;
    --success-color: #00c853;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --info-color: #03a9f4;

    /* Neutral Colors */
    --bg-body: #e8f0f8;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-sidebar: #0a2647;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-white: #ffffff;
    --border-color: #e0e0e0;

    /* Effects */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    --glass-blur: blur(10px);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 50%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.glass-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-left: 20px !important;
    padding-right: 20px !important;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--primary-dark);
    color: var(--text-white);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    /* Better mobile support */
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 70px;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: var(--spacing-lg);
    background-color: var(--bg-body);
    transition: all 0.3s ease;
}

.sidebar.collapsed+.main-content {
    margin-left: 70px;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--primary-dark);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.page-title {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: var(--spacing-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 6px rgba(13, 59, 102, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(13, 59, 102, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.card {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 59, 102, 0.2);
}

/* Sidebar Navigation */
.nav-links {
    list-style: none;
    padding: var(--spacing-md);
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Important for flex scrolling */
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nav-item {
    margin-bottom: var(--spacing-xs);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    gap: 12px;
    white-space: nowrap;
    position: relative;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
    border-left-color: var(--accent-color);
}

/* Collapsed Sidebar Adjustments */
.sidebar.collapsed .nav-link {
    padding-left: 17px;
    border-left-width: 4px;
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-section-header span {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: var(--spacing-lg) 0;
}

.sidebar.collapsed .nav-divider {
    text-align: center;
}

.sidebar.collapsed .nav-divider span {
    display: none;
}

.sidebar.collapsed .nav-divider::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin: 10px auto;
}

/* Section Divider Header (Non-collapsible) */
.nav-section-header {
    display: block;
    padding: 20px 16px 8px 16px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Nav subset is always visible */
.nav-subset {
    display: block;
}

.nav-link i {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-brand {
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand img {
    height: 40px;
}

.sidebar-brand span {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
}

/* Login Page Specifics */
.login-body {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    color: var(--primary-dark);
}

.login-header p {
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table th,
.table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: var(--text-primary);
}

/* Sticky Header for Payroll Table */
.payroll-table th {
    position: sticky;
    z-index: 10;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 8px;
    /* Compact padding */
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
    /* Subtle separator */
    vertical-align: middle;
}

/* First row headers (including rowspan) */
.payroll-table thead tr:first-child th {
    top: 0;
    z-index: 11;
    /* Higher than second row */
    height: 50px;
    /* Enforce height */
}

/* Second row headers (sub-columns) */
.payroll-table thead tr:nth-child(2) th {
    top: 50px;
    /* Match first row height */
    z-index: 10;
    background-color: var(--primary-dark);
    font-size: 0.85rem;
    /* Slightly smaller for sub-headers */
}

/* Ensure generic table header color doesn't override if we want specific styling */
.payroll-table th {
    background-color: var(--primary-dark);
    /* Using primary-dark based on screenshot green header */
    color: white;
}

.table tr:hover {
    background-color: #f9f9f9;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grid-cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #e3f2fd;
    color: #0d3b66;
}

.badge-warning {
    background: #fff3e0;
    color: #f57c00;
}

.badge-danger {
    background: #ffebee;
    color: #c62828;
}

/* ============================================
   RESPONSIVE BREAKPOINTS FOR GRIDS
   ============================================ */

/* Large screens (1200px+): 4 columns */
@media (min-width: 1200px) {
    .grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Medium-large screens (992px - 1199px): 3 columns for grid-4 */
@media (min-width: 992px) and (max-width: 1199px) {
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablets (768px - 991px): 2 columns */
@media (min-width: 768px) and (max-width: 991px) {

    .grid-cols-4,
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile (below 768px): 1 column - handled in existing media query */

/* Responsive */
/* Overlay for Sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    /* Below sidebar (1000) */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Helper Utilities */
.text-wrap {
    white-space: normal;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        /* Shadow handled by overlay */
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: var(--spacing-md);
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    /* Improve Header Wrapping */
    .flex-between {
        flex-wrap: wrap;
        gap: 15px;
    }

    .glass-header {
        position: relative;
        top: auto;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
    }

    /* Force Profile section to right or full width on mobile */
    .glass-header>a {
        width: 100%;
        justify-content: flex-start;
        padding-top: 10px;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    /* Universal fix for all profile images to prevent squashing */
    img[src*="ui-avatars"],
    #profileImage,
    .glass-header img {
        object-fit: cover !important;
        aspect-ratio: 1/1 !important;
        flex-shrink: 0 !important;
    }

    .glass-header h2 {
        font-size: 1.5rem;
    }

    .glass-header p {
        font-size: 0.9rem;
    }

    /* Sidebar Toggle positioning */
    #sidebarToggle {
        width: 44px !important;
        /* Larger touch target */
        height: 44px !important;
        padding: 0 !important;
        margin-right: 15px;
        margin-bottom: 0 !important;
        border-radius: 8px;
        display: inline-flex !important;
        justify-content: center;
        align-items: center;
        z-index: 1001;
        /* Ensure above header backdrop */
        cursor: pointer;
        position: relative;
        /* Context for z-index */
    }

    /* Ensure title aligns with button */
    .glass-header>div:first-child {
        width: 100%;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }

    .glass-header>div:first-child h2 {
        flex: 1;
        min-width: 200px;
        margin-bottom: 0;
    }

    .glass-header>div:first-child p {
        width: 100%;
        margin-left: 50px;
        /* Offset for button */
        margin-top: 5px;
    }

    /* Card Adjustments */
    .card {
        padding: var(--spacing-md);
    }

    /* Clock adjustments */
    .big-clock {
        font-size: 2.5rem;
    }

    /* Button adjustments */
    .btn {
        width: 100%;
        justify-content: center;
    }

    .clock-buttons {
        flex-direction: column;
    }
}

/* Toast Notification */
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px;
    position: fixed;
    z-index: 10000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

.toast.success {
    background-color: #22c55e;
}

.toast.error {
    background-color: #ef4444;
}

.toast.info {
    background-color: #3b82f6;
}

/* Template Cards */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.template-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    background: #fff;
    border-color: var(--primary-light);
}

/* Active State for Visual Feedback */
.template-card.active {
    background-color: #e3f2fd;
    /* Light blue background */
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 59, 102, 0.1);
}

.template-card i {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.template-card span {
    font-weight: 600;
    font-size: 0.9rem;
}

.template-card small {
    color: #6c757d;
    font-size: 0.75rem;
}

/* Mobile Responsiveness Improvements */
@media (max-width: 768px) {

    /* Stack flex containers that are buttons */
    .mt-3[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Target specific button groups in jadwal-kerja.html */
    #shiftModal .mt-3 button,
    #groupModal .mt-3 button,
    #applyGroupModal .mt-3 button,
    .action-buttons-container {
        width: 100%;
        display: flex;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .action-buttons-container button {
        width: 100% !important;
        margin-bottom: 5px;
    }

    /* Adjust quick template grid */
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols on mobile */
    }

    /* Modal widths */
    .modal-content {
        width: 95% !important;
        margin: 10px auto;
        padding: 15px;
    }

    /* Stack grid columns in forms */
    .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Button Actions in Cards */
.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-edit {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

.btn-edit:hover {
    background: var(--warning-color);
    color: #fff;
}

.btn-delete {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
}

.btn-delete:hover {
    background: var(--danger-color);
    color: #fff;
}

/* Modal Fixes */
.modal-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    /* managed by JS */
    opacity: 0;
    transition: opacity 0.3s;
    /* ... other existing modal styles likely exist but ensuring these */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    opacity: 1;
}

/* Modal Content - Solid Background */
.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    margin-bottom: var(--spacing-md);
}

.info-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 150px;
    flex-shrink: 0;
}

.info-value {
    color: var(--text-primary);
    flex: 1;
}