/* ============================================================
   Common.css — 전역 기본 스타일
   Theme: Clean Slate (눈 편한 회색/파란 계열)
   ============================================================ */

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1e293b;
    background-color: #f1f5f9;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ============================================================
   레이아웃
   ============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   사이드바 — 다크 슬레이트 (눈 편함)
   ============================================================ */
.sidebar {
    width: 240px;
    min-height: 100vh;
    background: #1e293b;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
    box-shadow: 1px 0 0 rgba(255,255,255,0.06);
}

.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: #3b82f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-text h1 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.sidebar-brand-text .brand-sub {
    font-size: 0.68rem;
    color: #475569;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0 16px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-section {
    padding: 16px 18px 5px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    font-size: 0.855rem;
    color: #94a3b8;
    transition: all 0.15s;
    margin: 1px 8px;
    border-radius: 8px;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.sidebar-nav a.active {
    background: #3b82f6;
    color: #fff;
    font-weight: 600;
}

.sidebar-nav a i {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.88rem;
}

/* 사이드바 체험기간 */
.sidebar-trial {
    margin: 6px 12px 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(59,130,246,0.10);
    border: 1px solid rgba(59,130,246,0.20);
    color: #93c5fd;
    font-size: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}
.sidebar-trial strong { color: #bfdbfe; }
.sidebar-trial-end {
    width: 100%;
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 2px;
}
.sidebar-trial.warning {
    background: rgba(234,179,8,0.10);
    border-color: rgba(234,179,8,0.25);
    color: #fde68a;
}
.sidebar-trial.warning strong { color: #fef08a; }
.sidebar-trial.danger {
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.25);
    color: #fca5a5;
}
.sidebar-trial.danger strong { color: #fecaca; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.72rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================================
   메인 콘텐츠
   ============================================================ */
.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================
   상단 헤더
   ============================================================ */
.top-header {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.top-header .page-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.top-header .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.845rem;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 4px 12px 4px 4px;
}

.user-badge .role-tag {
    background: #e0f2fe;
    color: #0369a1;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.user-badge .role-tag.admin {
    background: #3b82f6;
    color: #fff;
}

/* 모바일 햄버거 */
.sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-toggle:hover { background: #f1f5f9; }

/* ============================================================
   페이지 바디
   ============================================================ */
.page-body {
    padding: 22px 24px;
    flex: 1;
}

/* ============================================================
   카드
   ============================================================ */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 18px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

/* ============================================================
   버튼
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 0.845rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 1px 4px rgba(59,130,246,0.25);
}
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-secondary {
    background: #fff;
    color: #475569;
    border-color: #cbd5e1;
}
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; color: #1e293b; }

.btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.btn-success {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}
.btn-success:hover { background: #16a34a; border-color: #16a34a; }

.btn-warning {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}
.btn-warning:hover { background: #d97706; border-color: #d97706; }

.btn-ghost {
    background: transparent;
    color: #64748b;
    border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; color: #1e293b; }

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
    gap: 4px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.72rem;
    border-radius: 4px;
    gap: 3px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 6px;
}

/* ============================================================
   테이블
   ============================================================ */
.data-table {
    width: 100%;
    font-size: 0.845rem;
}

.data-table thead tr {
    background: #f8fafc;
}

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

/* ============================================================
   뱃지
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending  { background: #fef9c3; color: #854d0e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-active   { background: #dbeafe; color: #1d4ed8; }
.badge-inactive { background: #f1f5f9; color: #94a3b8; }

/* ============================================================
   폼
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.form-label.required::after {
    content: ' *';
    color: #ef4444;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-control:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.form-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* 토글 스위치 */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.toggle-label {
    font-size: 0.845rem;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 11px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-track {
    background: #3b82f6;
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(16px);
}

/* ============================================================
   페이지네이션
   ============================================================ */
.pagination {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
    padding: 16px 0 8px;
}

.page-btn {
    min-width: 33px;
    height: 33px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-size: 0.82rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.page-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.page-btn.active { background: #3b82f6; border-color: #3b82f6; color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   빈 상태
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 52px 20px;
    color: #94a3b8;
}

.empty-state .empty-icon {
    width: 56px;
    height: 56px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 1.4rem;
    color: #cbd5e1;
}

.empty-state p {
    font-size: 0.88rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.empty-state .empty-sub {
    font-size: 0.8rem;
    color: #cbd5e1;
}

/* ============================================================
   모달
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    color: #3b82f6;
    font-size: 0.9rem;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-close:hover { background: #f1f5f9; color: #1e293b; }

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: #fafbfc;
    border-radius: 0 0 12px 12px;
}

/* ============================================================
   통계 카드
   ============================================================ */
.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }

.stat-info { flex: 1; min-width: 0; }

.stat-info .stat-label {
    font-size: 0.76rem;
    color: #64748b;
    margin-bottom: 5px;
    font-weight: 500;
}

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1;
    letter-spacing: -0.5px;
}

.stat-info .stat-value span {
    font-size: 0.9rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 2px;
}

.stat-info .stat-sub {
    font-size: 0.74rem;
    color: #94a3b8;
    margin-top: 5px;
}

/* ============================================================
   토스트
   ============================================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #94a3b8;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    min-width: 280px;
    max-width: 360px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: all;
    animation: toastIn 0.22s cubic-bezier(.22,1,.36,1);
}

.toast-item.success { border-left-color: #22c55e; }
.toast-item.error   { border-left-color: #ef4444; }
.toast-item.warning { border-left-color: #f59e0b; }
.toast-item.info    { border-left-color: #3b82f6; }

.toast-icon { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.toast-item.success .toast-icon { color: #22c55e; }
.toast-item.error   .toast-icon { color: #ef4444; }
.toast-item.warning .toast-icon { color: #f59e0b; }
.toast-item.info    .toast-icon { color: #3b82f6; }

.toast-msg { font-size: 0.845rem; color: #334155; line-height: 1.45; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ============================================================
   확인 다이얼로그
   ============================================================ */
#confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#confirm-overlay.show { display: flex; animation: fadeIn 0.15s ease; }

#confirm-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px 28px 22px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
    animation: slideUp 0.2s ease;
}

#confirm-box .confirm-icon {
    font-size: 2.2rem;
    color: #f59e0b;
    margin-bottom: 14px;
}

#confirm-box .confirm-msg {
    font-size: 0.95rem;
    color: #334155;
    margin-bottom: 22px;
    line-height: 1.6;
}

#confirm-box .confirm-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ============================================================
   아바타
   ============================================================ */
.avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-circle.sm {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
}

.avatar-circle.md {
    width: 36px;
    height: 36px;
    font-size: 0.88rem;
}

/* ============================================================
   알림 인라인
   ============================================================ */
.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.845rem;
    margin-bottom: 16px;
}

.alert-box i { flex-shrink: 0; margin-top: 1px; }

.alert-box.info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-box.warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-box.danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-box.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ============================================================
   필터탭 공통
   ============================================================ */
.filter-tabs {
    display: flex;
    gap: 3px;
    background: #f1f5f9;
    border-radius: 9px;
    padding: 3px;
}

.filter-tab {
    padding: 5px 13px;
    border-radius: 7px;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-tab:hover { color: #1e293b; background: rgba(255,255,255,0.8); }

.filter-tab.active {
    background: #fff;
    color: #1e293b;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 총 건수 뱃지 */
.total-badge {
    display: inline-flex;
    align-items: center;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-240px);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,0.4);
        z-index: 199;
        display: none;
    }

    .sidebar-backdrop.show { display: block; }

    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .page-body { padding: 16px; }
}

@media (max-width: 600px) {
    .data-table th, .data-table td { padding: 8px 10px; }
    .modal-box { max-width: 100%; margin: 0; border-radius: 16px 16px 0 0; }
    .modal-overlay { align-items: flex-end; padding: 0; }
}
