/**
 * Hotel ERP - Global Component Classes
 *
 * 모든 앱에서 공통으로 사용하는 컴포넌트 클래스입니다.
 * 인라인 스타일 대신 이 클래스들을 사용하세요.
 *
 * 디자인 원칙 (Planner template 기반):
 * - 모든 색상은 CSS 변수 사용 (하드코딩 금지)
 * - 그라데이션 없음, 극미세 그림자 (0 1px 2px rgba(0,0,0,0.05))
 * - border-radius: 6px 표준 (var(--radius-md)), 카드는 8px (var(--radius-lg))
 * - focus: outline 2px blue-500, offset 2px (ring/box-shadow 아님)
 * - 타이포그래피: 14px 베이스, 헤딩 font-weight 600
 *
 * @see design_guide.md
 */

/* ==========================================================================
 * 1. Page Header
 * ========================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.125rem; /* text-lg = 18px */
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    line-height: 1.4;
}

.page-title i {
    color: var(--primary);
    font-size: 1rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ==========================================================================
 * 2. Filter Section
 * ========================================================================== */
.filter-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.875rem;
    align-items: flex-end;
    flex-wrap: wrap;
    box-shadow: var(--shadow-xs);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.filter-group select,
.filter-group input[type="date"],
.filter-group input[type="text"],
.filter-group input[type="month"],
.filter-group input[type="number"] {
    padding: 0.4375rem 0.75rem;
    border: 1px solid var(--input-border, var(--border-color));
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 140px;
    box-shadow: var(--shadow-xs);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--input-focus-border, var(--primary));
}

.filter-pills {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-sub);
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.filter-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.filter-pill.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* ==========================================================================
 * 3. Stats Row / Stat Cards
 * ========================================================================== */
.stats-row,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.15s;
}

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

/* Legacy pattern: .stat-card > .label + .value (no .stat-card-icon) */
.stat-card:not(:has(.stat-card-icon)) {
    flex-direction: column;
    gap: 0.25rem;
}

/* Icon circle — kept for backward compat, visually simplified */
.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.stat-card-icon.primary   { background: var(--primary-light);  color: var(--primary); }
.stat-card-icon.success   { background: var(--success-light);  color: var(--success); }
.stat-card-icon.danger    { background: var(--danger-light);   color: var(--danger); }
.stat-card-icon.warning   { background: var(--warning-light);  color: var(--warning); }
.stat-card-icon.info      { background: var(--info-light);     color: var(--info); }
.stat-card-icon.secondary { background: var(--secondary-light);color: var(--secondary); }
.stat-card-icon.orange    { background: var(--orange-light, #fff7ed); color: var(--orange, #f97316); }

.stat-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.stat-card-label {
    font-size: 0.8125rem;
    color: var(--text-sub);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-card-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.stat-card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-card-value.positive { color: var(--success); }
.stat-card-value.negative { color: var(--danger); }

/* Legacy stat-card children (.label / .value) — used by profitability, reports, etc. */
.stat-card > .label {
    font-size: 0.8125rem;
    color: var(--text-sub);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-card > .value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

/* ==========================================================================
 * 4. Data Card / Section Title
 * ========================================================================== */
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.data-card-header h3,
.data-card-header .section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.data-card-header h3 i,
.data-card-header .section-title i {
    color: var(--primary);
    font-size: 0.9375rem;
}

.data-card-body {
    padding: 1.25rem;
}

.data-card-body.no-padding {
    padding: 0;
}

.section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--primary);
    font-size: 0.9375rem;
}

/* ==========================================================================
 * 5. Data Table
 * ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.6875rem 1rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-table-header);
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.8125rem;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.data-table tbody tr {
    transition: background-color 0.1s ease;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

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

.data-table tbody td {
    color: var(--text-sub);
    font-size: 0.875rem;
}

.data-table tfoot {
    font-weight: 600;
}

.data-table tfoot td {
    background: var(--bg-table-header);
    border-top: 2px solid var(--border-color);
}

.data-table .text-right  { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .text-primary { color: var(--primary); font-weight: 600; }

.data-table .empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem !important;
}

/* ==========================================================================
 * 6. Buttons
 * ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    padding: 0.5rem 0.75rem; /* py-8px px-12px */
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Primary — blue-500 */
.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border-color: transparent;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: transparent;
}

/* Success */
.btn-success {
    background: var(--success);
    color: #ffffff;
    border-color: transparent;
}

.btn-success:hover {
    background: var(--success-dark);
}

/* Danger / Destructive */
.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: transparent;
}

.btn-danger:hover {
    background: var(--danger-dark);
}

/* Warning */
.btn-warning {
    background: var(--warning);
    color: #ffffff;
    border-color: transparent;
}

.btn-warning:hover {
    background: var(--warning-dark);
}

/* Info */
.btn-info {
    background: var(--info);
    color: #ffffff;
    border-color: transparent;
}

.btn-info:hover {
    background: var(--info-dark);
}

/* Secondary — white bg, gray border */
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-dark);
}

/* Ghost — transparent, no border */
.btn-ghost,
.btn-outline {
    background: transparent;
    color: var(--text-sub);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover,
.btn-outline:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

/* Outline primary */
.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: none;
}

.btn-outline-primary:hover {
    background: var(--primary-light);
}

/* Outline danger */
.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
    box-shadow: none;
}

.btn-outline-danger:hover {
    background: var(--danger-light);
}

/* Sizes */
.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-md);
}

.btn-lg {
    padding: 0.6875rem 1.25rem;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
}

.btn-icon {
    padding: 0.5rem;
    min-width: 34px;
    min-height: 34px;
}

.btn-icon.btn-sm {
    padding: 0.3125rem;
    min-width: 28px;
    min-height: 28px;
}

/* ==========================================================================
 * 7. Tab Wrapper (App Navigation)
 * ========================================================================== */
.app-tabs-wrapper {
    margin-bottom: 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.app-tabs {
    display: flex;
    gap: 0;
}

.app-tabs .tab-btn {
    border-radius: 0;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
    gap: 6px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-sub);
    font-weight: 500;
}

.app-tabs .tab-btn i {
    font-size: 1rem;
}

.app-tabs .tab-btn .tab-label {
    font-size: 0.8125rem;
    font-weight: 500;
}

.app-tabs .tab-btn:hover {
    background: transparent;
    color: var(--text-main);
    border-bottom-color: var(--border-color);
}

.app-tabs .tab-btn.active {
    background: transparent;
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.app-tabs .tab-btn.active i,
.app-tabs .tab-btn.active .tab-label {
    color: var(--primary);
}

/* Responsive tabs */
@media (max-width: 1200px) {
    .app-tabs .tab-btn {
        padding: 8px 12px;
    }
    .app-tabs .tab-btn .tab-label {
        display: none;
    }
    .app-tabs .tab-btn i {
        font-size: 1.1rem;
    }
}

@media (min-width: 1400px) {
    .app-tabs .tab-btn {
        padding: 10px 16px;
    }
    .app-tabs .tab-btn i {
        font-size: 1rem;
    }
    .app-tabs .tab-btn .tab-label {
        font-size: 0.8125rem;
    }
}

/* Tab dropdown (for grouped sub-menus) */
.tab-dropdown {
    position: relative;
}

.tab-dropdown .tab-btn::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    vertical-align: middle;
}

.tab-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    min-width: 160px;
    z-index: var(--z-dropdown, 100);
    display: none;
    padding-top: 8px;
}

/* 투명 브릿지로 버튼↔메뉴 사이 hover 유지 */
.tab-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.tab-dropdown:hover .tab-dropdown-menu {
    display: block;
}

.tab-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-sub);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.1s, color 0.1s;
}

.tab-dropdown-menu a:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

.tab-dropdown-menu a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.tab-dropdown-menu a i {
    font-size: 0.9375rem;
    width: 18px;
    text-align: center;
}

.tab-dropdown-menu .divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ==========================================================================
 * 8. Inline Tabs (border-bottom-2 Planner style)
 * ========================================================================== */
.inline-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.inline-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-sub);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.inline-tab:hover {
    color: var(--text-main);
    border-bottom-color: var(--border-dark);
}

.inline-tab.active,
.inline-tab[aria-current="page"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ==========================================================================
 * 9. Side Navigation (for approvals-like layouts)
 * ========================================================================== */
.side-nav {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
}

.side-nav-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    color: var(--text-sub);
    text-decoration: none;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.1s, color 0.1s;
    font-size: 0.875rem;
}

.side-nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

.side-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.side-nav-item:last-child {
    border-bottom: none;
}

.side-nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #ffffff;
    padding: 0.125rem 0.4375rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
}

/* ==========================================================================
 * 10. Form Elements
 * ========================================================================== */
.form-group {
    margin-bottom: 1.125rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 0.1875rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input-border, var(--border-color));
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-xs);
}

.form-control:hover {
    border-color: var(--border-dark);
}

.form-control:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--input-focus-border, var(--primary));
    box-shadow: 0 0 0 3px var(--input-focus-ring, rgba(59, 130, 246, 0.1));
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.25rem;
}

textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .flex-1 { flex: 1; }
.form-row .flex-2 { flex: 2; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ==========================================================================
 * 11. Alerts
 * ========================================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border-left: 3px solid;
}

.alert-success {
    background: var(--success-light);
    border-left-color: var(--success);
    color: var(--success-dark);
}

.alert-warning {
    background: var(--warning-light);
    border-left-color: var(--warning);
    color: var(--warning-dark);
}

.alert-danger,
.alert-error {
    background: var(--danger-light);
    border-left-color: var(--danger);
    color: var(--danger-dark);
}

.alert-info {
    background: var(--info-light);
    border-left-color: var(--info);
    color: var(--info-dark);
}

/* ==========================================================================
 * 12. Modal
 * ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 1000);
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.18s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.97) translateY(-8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-lg { width: 800px;  max-width: 95vw; }
.modal-md { width: 520px;  max-width: 95vw; }
.modal-sm { width: 400px;  max-width: 95vw; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    background: transparent;
    border: 1px solid transparent;
    font-size: 1.125rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3125rem;
    border-radius: var(--radius-md);
    line-height: 1;
    transition: background-color 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
 * 13. Pagination
 * ========================================================================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span,
.page-link {
    padding: 0.4375rem 0.75rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-weight: 500;
    font-size: 0.875rem;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    box-shadow: var(--shadow-xs);
}

.pagination a:hover,
.page-link:hover:not(.active):not(.current) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pagination .current,
.page-link.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ==========================================================================
 * 14. Status Badges
 * ========================================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.5rem; /* py-4px px-8px */
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    line-height: 1;
    /* ring-1 ring-inset pattern via box-shadow inset */
    box-shadow: inset 0 0 0 1px currentColor;
}

.status-badge-pending,
.status-pending {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.3);
}

.status-badge-approved,
.status-badge-active,
.status-badge-success,
.status-approved,
.status-completed,
.status-matched {
    background: var(--badge-success-bg);
    color: var(--badge-success-text);
    box-shadow: inset 0 0 0 1px rgba(4, 120, 87, 0.3);
}

.status-badge-rejected,
.status-badge-failed,
.status-badge-danger,
.status-rejected,
.status-unmatched {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.2);
}

.status-badge-info,
.status-posted {
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.status-badge-secondary,
.status-draft,
.status-cancelled,
.status-excluded {
    background: var(--badge-default-bg);
    color: var(--badge-default-text);
    box-shadow: inset 0 0 0 1px rgba(107, 114, 128, 0.25);
}

.status-badge-default {
    background: var(--badge-default-bg);
    color: var(--badge-default-text);
    box-shadow: inset 0 0 0 1px rgba(107, 114, 128, 0.25);
}

/* Uppercase status variants (backward compatibility) */
.status-DRAFT     { background: var(--badge-default-bg); color: var(--badge-default-text); box-shadow: inset 0 0 0 1px rgba(107,114,128,0.25); }
.status-PENDING   { background: var(--badge-warning-bg); color: var(--badge-warning-text); box-shadow: inset 0 0 0 1px rgba(217,119,6,0.3); }
.status-APPROVED  { background: var(--badge-info-bg);    color: var(--badge-info-text);    box-shadow: inset 0 0 0 1px rgba(37,99,235,0.3); }
.status-REJECTED  { background: var(--badge-danger-bg);  color: var(--badge-danger-text);  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.2); }
.status-COMPLETED { background: var(--badge-success-bg); color: var(--badge-success-text); box-shadow: inset 0 0 0 1px rgba(4,120,87,0.3); }
.status-POSTED    { background: var(--badge-info-bg);    color: var(--badge-info-text);    box-shadow: inset 0 0 0 1px rgba(37,99,235,0.3); }
.status-CANCELLED { background: var(--badge-default-bg); color: var(--badge-default-text); box-shadow: inset 0 0 0 1px rgba(107,114,128,0.25); }
.status-ACTIVE    { background: var(--badge-success-bg); color: var(--badge-success-text); box-shadow: inset 0 0 0 1px rgba(4,120,87,0.3); }
.status-EXPIRED   { background: var(--badge-danger-bg);  color: var(--badge-danger-text);  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.2); }
.status-TERMINATED{ background: var(--badge-danger-bg);  color: var(--badge-danger-text);  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.2); }
.status-CONFIRMED { background: var(--badge-info-bg);    color: var(--badge-info-text);    box-shadow: inset 0 0 0 1px rgba(37,99,235,0.3); }
.status-PAID      { background: var(--badge-success-bg); color: var(--badge-success-text); box-shadow: inset 0 0 0 1px rgba(4,120,87,0.3); }

/* Badge variant (non-pill) — ring-1 ring-inset pattern */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem; /* py-4px px-8px */
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    line-height: 1;
}

/* Default: bg-gray-50, text-gray-900, ring-gray-500/30 */
.badge-primary   {
    background: var(--badge-primary-bg);
    color: var(--badge-primary-text);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.3);
}
/* Success: bg-emerald-50, text-emerald-900, ring-emerald-600/30 */
.badge-success   {
    background: var(--badge-success-bg);
    color: var(--badge-success-text);
    box-shadow: inset 0 0 0 1px rgba(4, 120, 87, 0.3);
}
/* Warning: bg-yellow-50, text-yellow-900, ring-yellow-600/30 */
.badge-warning   {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.3);
}
/* Error: bg-red-50, text-red-900, ring-red-600/20 */
.badge-danger    {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
    box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.2);
}
/* Info (blue): bg-blue-50, text-blue-900, ring-blue-500/30 */
.badge-info      {
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3);
}
.badge-secondary {
    background: var(--badge-secondary-bg);
    color: var(--badge-secondary-text);
    box-shadow: inset 0 0 0 1px rgba(109, 40, 217, 0.25);
}
/* Default gray */
.badge-gray      {
    background: var(--badge-default-bg);
    color: var(--badge-default-text);
    box-shadow: inset 0 0 0 1px rgba(107, 114, 128, 0.3);
}

/* Priority badges */
.priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-md);
}

.priority-low,   .priority-LOW    { background: var(--badge-default-bg); color: var(--badge-default-text); box-shadow: inset 0 0 0 1px rgba(107,114,128,0.25); }
.priority-normal,.priority-NORMAL { background: var(--badge-info-bg);    color: var(--badge-info-text);    box-shadow: inset 0 0 0 1px rgba(59,130,246,0.3); }
.priority-high,  .priority-HIGH   { background: var(--badge-warning-bg); color: var(--badge-warning-text); box-shadow: inset 0 0 0 1px rgba(217,119,6,0.3); }
.priority-urgent,.priority-URGENT { background: var(--badge-danger-bg);  color: var(--badge-danger-text);  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.2); }

/* ==========================================================================
 * 15. Stat Icon Backgrounds (kept for backward compat)
 * ========================================================================== */
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    font-size: 1.375rem;
}

.stat-icon-primary   { background: var(--primary-light);  color: var(--primary); }
.stat-icon-secondary { background: var(--secondary-light);color: var(--secondary); }
.stat-icon-info      { background: var(--info-light);     color: var(--info); }
.stat-icon-success   { background: var(--success-light);  color: var(--success); }
.stat-icon-warning   { background: var(--warning-light);  color: var(--warning); }
.stat-icon-danger    { background: var(--danger-light);   color: var(--danger); }
.stat-icon-gold      { background: var(--accent-gold-light); color: var(--accent-gold); }

.stat-icon-lg { width: 56px; height: 56px; font-size: 1.75rem; border-radius: var(--radius-md); }
.stat-icon-sm { width: 32px; height: 32px; font-size: 1rem;    border-radius: var(--radius-sm); }

/* ==========================================================================
 * 16. Card Styles (kept for backward compat)
 * ========================================================================== */
.theme-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary);
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--primary);
}

/* ==========================================================================
 * 17. Chart Container
 * ========================================================================== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
}

.chart-container h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container h3 i {
    color: var(--primary);
}

/* ==========================================================================
 * 18. Empty State / Loading
 * ========================================================================== */
.empty-state,
.loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-sub);
}

.empty-state i,
.loading-state i {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.4;
}

.empty-state h3 {
    margin: 0 0 0.4rem 0;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
}

.empty-state p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ==========================================================================
 * 19. Year Navigator
 * ========================================================================== */
.year-navigator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.1875rem;
    box-shadow: var(--shadow-xs);
}

.year-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-sub);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.year-nav-btn:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
}

.year-nav-btn:active {
    opacity: 0.75;
}

.year-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.875rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-main);
    min-width: 90px;
    justify-content: center;
}

.year-display i {
    color: var(--primary);
}

/* ==========================================================================
 * 20. Progress Bar
 * ========================================================================== */
.progress-bar {
    background: var(--border-color);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* ==========================================================================
 * 21. Search Box
 * ========================================================================== */
.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9375rem;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.875rem 0.5rem 2.5rem;
    border: 1px solid var(--input-border, var(--border-color));
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-xs);
}

.search-box input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--input-focus-border, var(--primary));
    box-shadow: 0 0 0 3px var(--input-focus-ring, rgba(59, 130, 246, 0.1));
}

/* ==========================================================================
 * 22. Detail Grid (key-value layout)
 * ========================================================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.625rem 1rem;
}

.detail-grid dt {
    font-weight: 500;
    color: var(--text-sub);
    font-size: 0.875rem;
}

.detail-grid dd {
    color: var(--text-main);
    font-size: 0.875rem;
    margin: 0;
}

/* ==========================================================================
 * 23. Grid Layouts
 * ========================================================================== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 992px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .stats-row-4, .stats-row-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-row-4, .stats-row-3, .stats-row {
        grid-template-columns: 1fr;
    }
    .form-row {
        flex-direction: column;
    }
    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ==========================================================================
 * 24. Approval Steps
 * ========================================================================== */
.approval-steps {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--bg-card-hover);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--text-sub);
    font-weight: 500;
}

.step-item.pending  { background: var(--warning-light);color: var(--warning-dark); }
.step-item.approved { background: var(--success-light);color: var(--success-dark); }
.step-item.rejected { background: var(--danger-light); color: var(--danger-dark); }

.step-arrow {
    color: var(--text-muted);
}

/* ==========================================================================
 * 25. Profit/Ratio Colors
 * ========================================================================== */
.profit-positive { color: var(--success); }
.profit-negative { color: var(--danger); }

.ratio-good {
    color: var(--success-dark);
    background: var(--success-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.ratio-warning {
    color: var(--warning-dark);
    background: var(--warning-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.ratio-bad {
    color: var(--danger-dark);
    background: var(--danger-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
 * 26. Text Utility Classes
 * ========================================================================== */
.text-theme-main    { color: var(--text-main); }
.text-theme-sub     { color: var(--text-sub); }
.text-theme-muted   { color: var(--text-muted); }
.text-theme-primary { color: var(--primary); }
.text-theme-success { color: var(--success); }
.text-theme-danger  { color: var(--danger); }
.text-theme-warning { color: var(--warning); }
.text-theme-info    { color: var(--info); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.75rem; }

/* ==========================================================================
 * 27. Background Utility Classes
 * ========================================================================== */
.bg-theme-body         { background: var(--bg-body); }
.bg-theme-card         { background: var(--bg-card); }
.bg-theme-primary      { background: var(--primary); }
.bg-theme-primary-light{ background: var(--primary-light); }

/* ==========================================================================
 * 28. Gradient Buttons (kept for backward compat, prefer .btn-primary)
 * ========================================================================== */
.btn-gradient-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    transition: background-color 0.15s;
}

.btn-gradient-primary:hover {
    background: var(--primary-hover);
}

/* ==========================================================================
 * 29. Table Responsive Wrapper
 * ========================================================================== */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

/* ==========================================================================
 * 30. File Icons
 * ========================================================================== */
.file-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
}

.file-icon.pdf     { background: var(--danger-light);        color: var(--danger); }
.file-icon.doc     { background: var(--info-light);          color: var(--info); }
.file-icon.hwp     { background: var(--success-light);       color: var(--success); }
.file-icon.default { background: var(--badge-default-bg);    color: var(--text-sub); }

/* ==========================================================================
 * 31. Transitions
 * ========================================================================== */
.transition-fast   { transition: all var(--transition-fast); }
.transition-normal { transition: all var(--transition-normal); }
.transition-slow   { transition: all var(--transition-slow); }

/* ==========================================================================
 * 32. Action Cards (dashboard links)
 * ========================================================================== */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none;
    transition: box-shadow 0.15s;
    box-shadow: var(--shadow-xs);
}

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

.action-card.warning { border-left: 3px solid var(--warning); }
.action-card.info    { border-left: 3px solid var(--info); }
.action-card.danger  { border-left: 3px solid var(--danger); }
.action-card.success { border-left: 3px solid var(--success); }

.action-icon {
    position: relative;
    width: 44px;
    height: 44px;
    background: var(--bg-card-hover);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--text-sub);
    flex-shrink: 0;
}

.action-icon .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--radius-full);
    min-width: 16px;
    text-align: center;
    box-shadow: none;
}

.action-info        { flex: 1; min-width: 0; }
.action-info h3     { font-size: 0.9375rem; font-weight: 600; color: var(--text-main); margin: 0; }
.action-info p      { font-size: 0.875rem; color: var(--text-sub); margin: 0.1875rem 0 0; }

/* ==========================================================================
 * 33. Global Focus Visible (accessibility)
 * ========================================================================== */
:focus-visible {
    outline: 2px solid var(--focus-ring-color, var(--primary));
    outline-offset: 2px;
}
