@import url('css/buttons.css');

:root {
    --primary: #B69D90;
    --primary-light: #d1c1b7;
    --primary-dark: #8b7468;
    --bg-color: #fcfbf9; /* Soft off-white */
    --surface: #ffffff;
    --text-main: #3d3b3a;
    --text-muted: #8c8886;
    --border: #edeae6;
    --success: #6b8e6b;
    --danger: #b26c6c;
    --warning: #d9a05b; /* Soft Orange/Yellow */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

input, select, textarea {
    font-size: 16px;
    font-family: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar for PC */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
}
.brand img {
    max-width: 100%;
    max-height: 50px;
    object-fit: contain;
}

.nav-links {
    list-style: none;
    margin-top: 16px;
}

.nav-links li a {
    display: block;
    padding: 16px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links li a:hover, .nav-links li.active a {
    background-color: #f7f5f2;
    color: var(--primary-dark);
    border-left: 4px solid var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    height: 72px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.header-title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 1.1em;
    background-color: var(--primary);
    margin-right: 12px;
    border-radius: 3px;
}

.user-profile {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    overflow-y: auto;
    overflow-y: auto;
}

.card {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.card h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 500;
}

.card .value {
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--text-main);
}

.full-width {
    grid-column: 1 / -1;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    min-width: 600px;
}

.table th, .table td {
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.table thead {
    background-color: #f7f4f2;
}

.table th {
    color: #555;
    font-weight: 600;
}

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

.tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    background: var(--border);
    color: var(--text-muted);
    margin-left: 8px;
}


/* Responsive Mobile */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    body { flex-direction: column; }
    
    
    .header { padding: 0 20px; }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 20px;
        padding-bottom: 20px;
        gap: 16px;
    }
    
    
    
}

/* Table Column Alignment Classes */
.col-text { text-align: left !important; }
.col-num { text-align: right !important; }
.col-center { text-align: center !important; }

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--success); /* #608d72 */
    font-weight: 600;
}

.form-control {
    width: 100%;
    height: 42px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.2;
    color: var(--text-main);
    background: var(--bg-color);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c8886' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 32px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.hamburger { display: none; }

/* Chart Wrapper */
.chart-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 250px;
    margin: 0 auto;
}

.cost-table-wrapper {
    flex: 1;
    min-width: 300px;
}

.section-title {
    margin-bottom: 0 !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
}

/* Layout Standardization Classes */
.page-body {
    padding: 32px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 24px;
    align-items: stretch;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.stack-y {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
}

/* Segmented Control / Toggle Buttons */
.segment-group {
    display: flex;
    background: #f1f3f5;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}
.segment-group input[type="radio"] {
    display: none;
}
.segment-group label {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #868e96;
    margin: 0;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
.segment-group input[type="radio"]:checked + label {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Reports Specific Styles */
.report-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.financial-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: flex-start;
}
.financial-grid > .card {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
@media (max-width: 768px) {
    .financial-grid {
        grid-template-columns: 1fr;
    }
}
.fin-table {
    width: 100%;
    min-width: 100%;
    display: table;
    border-collapse: collapse;
    table-layout: fixed;
}
.fin-table th, .fin-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}
.fin-table td:first-child {
    text-align: left;
    color: var(--text-main);
    width: 60%;
}
.fin-table td.amount {
    text-align: right;
    font-weight: 600;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    width: 40%;
}
.fin-table tr.total {
    background-color: var(--surface-hover);
}
.fin-table tr.total td {
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    color: var(--text-main);
}
.fin-table tr.net-income td {
    color: var(--primary);
    font-size: 1.1rem;
}

/* ══════════════════════════════════════
   급여 관리 전용 스타일
   ══════════════════════════════════════ */

/* 탭 네비게이션 */
.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}
.tab-btn {
    padding: 12px 28px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}
/* 탭 패널 — 핵심: SPA 환경에서도 항상 이 규칙이 적용되어야 함 */
.tab-panel { display: none !important; }
.tab-panel.active { display: block !important; }

/* 급여 대장 그리드 */
.payroll-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 1000px;
}
.payroll-grid thead th {
    background: #f7f4f2;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.payroll-grid tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.payroll-grid tbody tr.confirmed { background: #f0f7f0; }
.payroll-grid tbody tr.confirmed td { color: var(--text-muted); }
.payroll-grid tfoot td {
    padding: 12px 8px;
    font-weight: 700;
    border-top: 2px solid var(--border);
    background: #f7f4f2;
}
.payroll-grid input[type="number"],
.payroll-grid input[type="text"] {
    width: 100%;
    height: 34px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.88rem;
    text-align: right;
    background: var(--bg-color);
    box-sizing: border-box;
}
.payroll-grid select {
    width: 100%;
    height: 34px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.88rem;
    background: var(--bg-color);
}
.payroll-grid input:disabled,
.payroll-grid select:disabled {
    background: #f0f0ee;
    color: var(--text-muted);
    cursor: not-allowed;
}
.payroll-grid .num { text-align: right; }
.payroll-grid .center { text-align: center; }

/* 상태 배지 */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-confirmed { background: #e6f4ea; color: var(--success); }
.badge-pending { background: #fef3e2; color: var(--warning); }
.badge-type-regular { background: #eef2fa; color: #3b68c4; }
.badge-type-director { background: #fdf5e6; color: #c48b3b; font-weight: bold; border: 1px solid #f6deb3; }
.badge-type-daily { background: #f5f5f5; color: var(--text-muted); }
.badge-type-foreign { background: #eef7ee; color: var(--success); }

/* 연월 선택 바 */
.ym-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ym-bar label { font-weight: 600; color: var(--text-muted); font-size: 0.9rem; }
.ym-bar input[type="month"] {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--bg-color);
}

/* 합계 카드 바 */
.summary-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    flex: 1;
    min-width: 140px;
    text-align: center;
}
.summary-card .sc-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.summary-card .sc-val { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.summary-card .sc-val.danger { color: var(--danger); }
.summary-card .sc-val.success { color: var(--success); }

/* 근로자 카드 그리드 */
.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.worker-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    position: relative;
    transition: box-shadow 0.2s;
}
.worker-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }
.worker-card .wc-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.worker-card .wc-detail { font-size: 0.85rem; color: var(--text-muted); line-height: 1.7; }
.worker-card .wc-rate { font-size: 1.0rem; font-weight: 600; color: var(--primary-dark); margin-top: 10px; }
.worker-card .wc-actions { display: flex; gap: 8px; margin-top: 12px; }
.worker-card.inactive { opacity: 0.5; }

/* 급여 관리 인라인 버튼 */
.btn-sm {
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary-dark);
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-sm:hover { background: var(--primary); color: #fff; }
.btn-sm.btn-confirm { border-color: var(--success); color: var(--success); }
.btn-sm.btn-confirm:hover { background: var(--success); color: #fff; }
.btn-sm.btn-unconfirm { border-color: var(--primary); color: var(--primary-dark); }
.btn-sm.btn-delete {
    border-color: rgba(182, 157, 144, 0.5);
    color: var(--text-muted);
}
.btn-sm.btn-delete:hover { background: rgba(182, 157, 144, 0.15); color: var(--text-main); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* 공제 컬럼 */
.col-deduct { min-width: 75px; }

/* 확정 모달 */
.confirm-modal { max-width: 440px; }

@media (max-width: 1200px) {
    .col-memo { display: none; }
}

/* Hide spin buttons for number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

@media print {
    body * {
        visibility: hidden;
    }
    #print-area, #print-area * {
        visibility: visible;
    }
    #print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
    }
}
