/* APIS 여권 자동화 시스템 - 디자인 시스템 */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 10px;
    --radius-lg: 14px;
}

body {
    background-color: var(--gray-50);
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--gray-700);
    line-height: 1.6;
}

/* 사이드바 */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--gray-900);
    color: white;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand {
    color: white; text-decoration: none;
    font-size: 1.3rem; font-weight: 800;
    letter-spacing: -0.02em;
}
.sidebar-brand:hover { color: white; }
.sidebar-brand i { color: var(--primary); margin-right: 0.3rem; }
.sidebar-nav {
    list-style: none; padding: 0.5rem 0.5rem; margin: 0;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: var(--gray-400); text-decoration: none;
    border-radius: 8px; font-size: 0.9rem; font-weight: 500;
    transition: all 0.15s;
}
.sidebar-link:hover { color: white; background: rgba(255,255,255,0.08); }
.sidebar-link.active { color: white; background: var(--primary); }
.sidebar-link i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-divider {
    height: 1px; background: rgba(255,255,255,0.08);
    margin: 0.5rem 0.75rem;
}
.sidebar-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--gray-500);
}
.sidebar-footer {
    padding: 0.5rem; border-top: 1px solid rgba(255,255,255,0.08);
}
.main-content {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}
.sidebar-toggle {
    position: fixed; top: 0.75rem; left: 0.75rem; z-index: 101;
    background: var(--primary); color: white; border: none;
    border-radius: 8px; width: 40px; height: 40px;
    font-size: 1.3rem; display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow);
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.3); }
    .main-content { margin-left: 0; padding: 1rem; width: 100%; padding-top: 3.5rem; }
}

/* 카드 */
.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

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

.card-header {
    border-bottom: 1px solid var(--gray-200);
    background: white;
    padding: 1rem 1.25rem;
}

/* 테이블 */
.table {
    font-size: 0.9rem;
}

.table th {
    white-space: nowrap;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom-width: 2px;
}

.table td {
    vertical-align: middle;
}

/* 버튼 */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

/* 폼 */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid var(--gray-200);
    padding: 0.6rem 0.85rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

/* 배지 */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-size: 0.8rem;
}

/* 알럿 */
.alert {
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
}

/* 페이지 헤더 */
h2 {
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

h2 i {
    color: var(--primary);
}

/* 브레드크럼 */
.breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* 요약 카드 */
.summary-card {
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: transform 0.15s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card .number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.summary-card .label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    display: block;
}

/* 드롭다운 */
.dropdown-menu {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--gray-100);
}

/* 모달 */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
}

/* 탭 */
.nav-tabs .nav-link {
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    color: var(--gray-500);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* 프린트 */
@media print {
    .navbar, footer, .btn, .breadcrumb, .alert, form { display: none !important; }
    .card { border: 1px solid #ddd !important; box-shadow: none !important; }
    .table { font-size: 0.75rem; }
    .badge { border: 1px solid #999; }
}

/* 반응형 */
@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    h2 { font-size: 1.4rem; }
    .table { font-size: 0.8rem; }
    .btn-group-sm .btn { padding: 0.25rem 0.5rem; }
}

/* 다크 모드 (data-theme="dark" 토글) */
[data-theme="dark"] body { background-color: #111827; color: #e5e7eb; }
[data-theme="dark"] .container { color: #e5e7eb; }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 { color: #f3f4f6; }
[data-theme="dark"] p, [data-theme="dark"] span, [data-theme="dark"] div,
[data-theme="dark"] td, [data-theme="dark"] th, [data-theme="dark"] li,
[data-theme="dark"] label, [data-theme="dark"] small { color: #e5e7eb; }

/* 카드 */
[data-theme="dark"] .card { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .card-header { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .card-body { background: #1f2937; color: #e5e7eb; }
[data-theme="dark"] .card-footer { background: #1f2937; border-color: #374151; }

/* 테이블 */
[data-theme="dark"] .table { color: #e5e7eb; }
[data-theme="dark"] .table th { color: #f3f4f6; }
[data-theme="dark"] .table td { color: #e5e7eb; border-color: #374151; }
[data-theme="dark"] .table-light th { background: #1f2937 !important; color: #f3f4f6 !important; }
[data-theme="dark"] .table-primary th { background: #1e3a5f !important; color: #f3f4f6 !important; }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .table-hover > tbody > tr:hover > td { background: rgba(255,255,255,0.07); }
[data-theme="dark"] .table-info { background: rgba(59,130,246,0.15) !important; }
[data-theme="dark"] .table-warning { background: rgba(234,179,8,0.15) !important; }
[data-theme="dark"] .table-danger { background: rgba(239,68,68,0.15) !important; }

/* 폼 */
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
    background: #1f2937; border-color: #4b5563; color: #f3f4f6;
}
[data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus {
    background: #1f2937; color: #f3f4f6; border-color: #60a5fa;
}
[data-theme="dark"] .form-control::placeholder { color: #9ca3af; }
[data-theme="dark"] .form-label { color: #d1d5db; }
[data-theme="dark"] .form-text { color: #9ca3af; }

/* 모달, 드롭다운 */
[data-theme="dark"] .modal-content { background: #1f2937; color: #e5e7eb; }
[data-theme="dark"] .modal-header { border-color: #374151; }
[data-theme="dark"] .modal-footer { border-color: #374151; }
[data-theme="dark"] .dropdown-menu { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .dropdown-item { color: #e5e7eb; }
[data-theme="dark"] .dropdown-item:hover { background: #374151; color: #f3f4f6; }

/* 알럿 */
[data-theme="dark"] .alert { background: #1f2937; color: #e5e7eb; border: 1px solid #374151; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fde68a; border-color: #92400e; }
[data-theme="dark"] .alert-info { background: #1e3a5f; color: #bfdbfe; border-color: #1e40af; }

/* 탭 */
[data-theme="dark"] .nav-tabs .nav-link { color: #9ca3af; }
[data-theme="dark"] .nav-tabs .nav-link.active { background: #1f2937; color: #60a5fa; border-color: #374151; }

/* 텍스트 */
[data-theme="dark"] .text-muted { color: #9ca3af !important; }
[data-theme="dark"] .text-dark { color: #e5e7eb !important; }
[data-theme="dark"] a { color: #60a5fa; }
[data-theme="dark"] .fw-bold, [data-theme="dark"] strong { color: #f3f4f6; }

/* 기타 */
[data-theme="dark"] .breadcrumb-item a { color: #60a5fa; }
[data-theme="dark"] .breadcrumb-item.active { color: #9ca3af; }
[data-theme="dark"] footer { border-color: #374151 !important; }
[data-theme="dark"] .btn-outline-secondary { color: #d1d5db; border-color: #4b5563; }
[data-theme="dark"] .btn-outline-secondary:hover { background: #374151; color: #f3f4f6; }
[data-theme="dark"] .btn-outline-primary { color: #60a5fa; border-color: #3b82f6; }
[data-theme="dark"] .btn-outline-danger { color: #f87171; border-color: #ef4444; }
[data-theme="dark"] .btn-close { filter: invert(1); }
[data-theme="dark"] .progress { background: #374151; }
[data-theme="dark"] .sidebar { background: #0a0a14; }
[data-theme="dark"] .sidebar-header { border-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .sidebar-footer { border-color: rgba(255,255,255,0.05); }

/* Bootstrap utility class들이 다크모드에서 흰 배경 강제하는 문제 — override */
[data-theme="dark"] .bg-light { background-color: #374151 !important; color: #e5e7eb !important; }
[data-theme="dark"] .bg-white { background-color: #1f2937 !important; color: #e5e7eb !important; }
[data-theme="dark"] .bg-body { background-color: #111827 !important; }
[data-theme="dark"] .text-dark { color: #e5e7eb !important; }
[data-theme="dark"] .text-black { color: #f3f4f6 !important; }
[data-theme="dark"] .border-light { border-color: #4b5563 !important; }
[data-theme="dark"] .border { border-color: #374151 !important; }
[data-theme="dark"] .border-top, [data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start, [data-theme="dark"] .border-end { border-color: #374151 !important; }

/* th에 직접 bg-light 적용된 경우 (results.html 검증 모달 등) */
[data-theme="dark"] th.bg-light,
[data-theme="dark"] th[class*="bg-light"] { background-color: #374151 !important; color: #f3f4f6 !important; }

/* 입력 그룹 / 리스트 그룹 */
[data-theme="dark"] .input-group-text { background: #374151; color: #e5e7eb; border-color: #4b5563; }
[data-theme="dark"] .list-group-item { background: #1f2937; color: #e5e7eb; border-color: #374151; }
[data-theme="dark"] .list-group-item:hover { background: #2d3748; }

/* 배지 — 다크모드에서 가독성 보강 */
[data-theme="dark"] .badge.bg-light { background-color: #4b5563 !important; color: #f3f4f6 !important; }
[data-theme="dark"] .badge.text-dark { color: #f3f4f6 !important; }

/* 폼 체크박스/라디오 라벨 */
[data-theme="dark"] .form-check-label { color: #e5e7eb; }
[data-theme="dark"] .form-check-input { background-color: #374151; border-color: #6b7280; }
[data-theme="dark"] .form-check-input:checked { background-color: #3b82f6; border-color: #3b82f6; }

/* placeholder / disabled */
[data-theme="dark"] .form-control:disabled, [data-theme="dark"] .form-select:disabled {
    background-color: #111827; color: #9ca3af; border-color: #374151;
}

/* 코드/pre 블록 */
[data-theme="dark"] code { background: #374151; color: #fbbf24; }
[data-theme="dark"] pre { background: #1f2937; color: #e5e7eb; border-color: #374151; }
[data-theme="dark"] kbd { background: #1f2937; color: #fbbf24; border-color: #374151; }

/* hr 구분선 */
[data-theme="dark"] hr { border-color: #374151; opacity: 0.8; }

/* 페이지네이션 */
[data-theme="dark"] .page-link { background: #1f2937; color: #60a5fa; border-color: #374151; }
[data-theme="dark"] .page-link:hover { background: #374151; color: #93c5fd; }
[data-theme="dark"] .page-item.active .page-link { background: #1e40af; border-color: #1e40af; color: #f3f4f6; }
[data-theme="dark"] .page-item.disabled .page-link { background: #1f2937; color: #6b7280; }
