/* --- Base Styles --- */
:root {
    --primary-color: #0F172A;
    /* Navy */
    --accent-color: #C5A059;
    /* Gold */
    --text-color: #333333;
    --border-color: #E2E8F0;
    --bg-color: #F8FAFC;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    display: block;
    /* Changed from flex center */
    padding: 0;
    margin: 0;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: #1e293b;
    color: white;
    padding: 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    font-size: 18px;
    margin: 0;
}

.btn-icon {
    background: var(--accent-color);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-list {
    list-style: none;
    padding: 0;
}

.user-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:hover {
    background-color: #475569;
}

.user-item.active {
    background-color: var(--accent-color);
    font-weight: bold;
}

.btn-delete-user {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    margin-left: 10px;
}

.btn-delete-user:hover {
    color: #ef4444;
}

/* Main Content Area */
.page-container {
    background-color: #FFFFFF;
    flex-grow: 1;
    max-width: none;
    /* remove max width to fill */
    min-height: 100vh;
    padding: 40px;
    box-shadow: none;
}

.no-print {
    /* Helper class */
}


/* --- Attendance Management Card Styles (Excel Style) --- */
.excel-container {
    padding: 20px;
    max-width: 297mm;
    /* Limit specific card width if needed, or let it flow */
    margin: 0 auto;
}

.month-card {
    background: white;
    margin-bottom: 50px;
    padding: 20px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.month-anchor {
    scroll-margin-top: 100px;
    /* Offset for sticky header if needed, or visual */
}

/* Nav */
.month-nav {
    display: flex;
    gap: 3px;
    /* Reduced */
    background: #f1f5f9;
    padding: 4px;
    border-radius: 4px;
}

.month-nav a {
    text-decoration: none;
    color: #475569;
    font-size: 11px;
    /* Reduced from 12px */
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.1s;
}

.month-nav a:hover {
    background: #cbd5e1;
    color: #0f172a;
}


.excel-header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}

.excel-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #000;
}

/* Control Bar (Top) */
.control-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding: 8px 0;
    /* Reduced from 10px */
    border-bottom: 1px solid #eee;
}

.clock-actions {
    display: flex;
    gap: 6px;
    /* Reduced from 10px */
    align-items: center;
}

.btn-mini {
    padding: 3px 8px;
    /* Reduced from 5px 15px */
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
    border-radius: 4px;
    font-size: 11px;
    /* Reduced from 13px */
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-mini:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.btn-mini.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-mini.accent {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Excel Table Structure */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'Malgun Gothic', 'Dotum', sans-serif;
    /* Excel-like fonts */
    border: 2px solid #000;
}

.excel-table th,
.excel-table td {
    border: 1px solid #666;
    /* Standard grid lines */
    padding: 4px 2px;
    text-align: center;
    vertical-align: middle;
    height: 28px;
}

/* Colors */
.bg-navy {
    background-color: #1a365d;
    color: white;
}

.bg-light-blue {
    background-color: #e0f2fe;
}

/* Check required */
.bg-red {
    background-color: #dc2626;
    color: white;
}

.bg-yellow {
    background-color: #ffff00;
    color: black;
    font-weight: bold;
}

/* Late Highlight */
.bg-orange {
    background-color: #fbbf24;
}

.bg-cyan {
    background-color: #06b6d4;
    color: white;
}

.bg-gray {
    background-color: #f3f4f6;
}

.text-red {
    color: #dc2626;
}

.text-blue {
    color: #2563eb;
}

/* Specific Column Widths */
.col-name {
    width: 80px;
}

.col-date {
    width: 80px;
}

.col-day {
    width: 50px;
}

.col-time {
    width: 80px;
}

.col-mini {
    width: 60px;
}

/* Merged Cells */
.cell-merged-sidebar {
    writing-mode: horizontal-tb;
    /* Image shows horizontal name */
    font-weight: bold;
    font-size: 16px;
    background: #fff;
    border-right: 2px solid #666;
}

/* Footer Summary Table */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 13px;
    border: 2px solid #000;
}

.summary-table th,
.summary-table td {
    border: 1px solid #666;
    padding: 5px;
    text-align: center;
}

.summary-header {
    background-color: #1a365d;
    color: white;
}

/* Responsive & Mobile Styles */
.mobile-only {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 250px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .page-container {
        padding: 10px;
        width: 100%;
    }

    .control-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        position: static;
        /* Unstick on mobile to save space */
    }

    .control-bar>div {
        flex-wrap: wrap;
        width: 100%;
    }

    .month-nav {
        overflow-x: auto;
        max-width: 100%;
        white-space: nowrap;
    }

    .clock-actions {
        flex-wrap: wrap;
    }

    /* Table Scroll */
    .excel-table {
        min-width: 800px;
        /* Force scroll */
    }

    .month-card {
        overflow-x: auto;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Print Overrides */
@media print {
    body {
        background: none;
        padding: 0;
        display: block;
    }

    .app-wrapper {
        display: block;
    }

    .sidebar {
        display: none !important;
    }

    .page-container {
        box-shadow: none;
        padding: 0;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .excel-container {
        padding: 0;
    }

    .month-card {
        page-break-after: always;
        /* Force new page for each month */
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        /* Ensure fits on page */
        width: 100%;
    }

    .control-bar,
    .nav-link {
        display: none !important;
    }

    .no-print {
        display: none !important;
    }

    /* Selection Masking */
    body.print-mask-active .month-card {
        display: none !important;
    }

    body.print-mask-active .is-printing {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .excel-table,
    .summary-table {
        border: 2px solid #000 !important;
    }

    .excel-table th,
    .excel-table td {
        border: 1px solid #000 !important;
    }

    /* Force background colors */
    .bg-navy {
        background-color: #1a365d !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
    }

    .bg-yellow {
        background-color: #ffff00 !important;
        -webkit-print-color-adjust: exact;
    }

    .bg-red {
        background-color: #dc2626 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
    }

    .bg-orange {
        background-color: #fbbf24 !important;
        -webkit-print-color-adjust: exact;
    }

    .bg-cyan {
        background-color: #06b6d4 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
    }
}