/* ============================================
 * 소리튠 APP - 공통 CSS
 * ============================================ */

:root {
    --main-bg: #6366F1;
    --main-bg-dark: #4F46E5;
    --main-bg-light: #EEF2FF;
    --accent: #F59E0B;
    --accent-light: #FEF3C7;

    /* Alert colors */
    --alert-normal: #4CAF50;
    --alert-yellow: #FFC107;
    --alert-red: #F44336;
    --alert-black: #212121;
    --alert-eliminated: #9E9E9E;

    /* UI colors */
    --white: #FFFFFF;
    --black: #333333;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;

    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #2196F3;

    /* DISC colors */
    --disc-d: #E53935;
    --disc-i: #FFB300;
    --disc-s: #43A047;
    --disc-c: #1E88E5;

    /* Grade colors */
    --grade-aplus: #FF6F00;
    --grade-a: #E65100;
    --grade-b: #2E7D32;
    --grade-c: #1565C0;
    --grade-d: #616161;
    --grade-intern: #9E9E9E;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.08);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-md: 15px;
    --font-size-lg: 18px;
    --font-size-xl: 22px;
    --font-size-2xl: 28px;
    --font-size-3xl: 36px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Safe area */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--black);
    background: var(--gray-100);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; line-height: inherit; border: none; outline: none; background: none; }
button { cursor: pointer; user-select: none; }
ul, ol { list-style: none; }

/* ============================================
 * Layout
 * ============================================ */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--white);
}

.app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--main-bg);
    color: var(--white);
    padding: calc(var(--safe-top) + 12px) 16px 12px;
    display: flex; align-items: center; justify-content: space-between;
    min-height: 56px;
}
.app-header h1 { font-size: var(--font-size-lg); font-weight: 700; letter-spacing: -0.5px; }
.app-header .header-sub { font-size: var(--font-size-xs); opacity: 0.8; }

.app-body {
    padding: var(--space-md);
    padding-bottom: calc(var(--safe-bottom) + 80px);
}

/* PC layout for system/operator dashboards */
.pc-layout {
    min-height: 100vh;
    background: var(--gray-50);
}
.pc-header {
    background: var(--main-bg);
    color: var(--white);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
}
.pc-header h1 { font-size: 20px; font-weight: 700; }
.pc-header-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.pc-nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    overflow-x: auto;
    padding: 0 16px;
    scrollbar-width: none;
}
.pc-nav::-webkit-scrollbar { display: none; }
.pc-nav a {
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-fast);
}
.pc-nav a:hover { color: var(--main-bg); }
.pc-nav a.active { color: var(--main-bg); border-bottom-color: var(--main-bg); }
.pc-body {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
 * Buttons
 * ============================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-md); font-weight: 600;
    font-size: var(--font-size-md); transition: all var(--transition-fast); white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--main-bg); color: var(--white); }
.btn-primary:active { background: var(--main-bg-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-outline { border: 2px solid var(--main-bg); color: var(--main-bg); }
.btn-sm { padding: 6px 12px; font-size: var(--font-size-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--font-size-lg); border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ============================================
 * Cards
 * ============================================ */
.card {
    background: var(--white); border-radius: var(--radius-lg);
    padding: var(--space-md); box-shadow: var(--shadow-card);
}
.card + .card { margin-top: var(--space-md); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--space-md);
}
.card-title { font-size: var(--font-size-lg); font-weight: 700; }

/* ============================================
 * Forms
 * ============================================ */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 12px 14px; border: 2px solid var(--gray-300);
    border-radius: var(--radius-md); font-size: var(--font-size-md);
    transition: border-color var(--transition-fast); background: var(--white);
}
.form-input:focus { border-color: var(--main-bg); }
.form-input::placeholder { color: var(--gray-400); }
select.form-input { appearance: auto; }

/* ============================================
 * Tags & Badges
 * ============================================ */
.tag {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: var(--radius-xl); font-size: var(--font-size-xs); font-weight: 600;
}
.tag-normal { background: #E8F5E9; color: #2E7D32; }
.tag-yellow { background: #FFF8E1; color: #E65100; }
.tag-red { background: #FFEBEE; color: #C62828; }
.tag-black { background: #333; color: #fff; }
.tag-active { background: var(--main-bg-light); color: var(--main-bg); }

/* DISC tags */
.tag-disc-d { background: #FFEBEE; color: var(--disc-d); }
.tag-disc-i { background: #FFF8E1; color: #F57F17; }
.tag-disc-s { background: #E8F5E9; color: var(--disc-s); }
.tag-disc-c { background: #E3F2FD; color: var(--disc-c); }

/* Grade tags */
.tag-grade-aplus { background: #FFF3E0; color: var(--grade-aplus); font-weight: 800; }
.tag-grade-a { background: #FBE9E7; color: var(--grade-a); }
.tag-grade-b { background: #E8F5E9; color: var(--grade-b); }
.tag-grade-c { background: #E3F2FD; color: var(--grade-c); }
.tag-grade-d { background: var(--gray-100); color: var(--grade-d); }
.tag-grade-intern { background: var(--gray-100); color: var(--grade-intern); }

.badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    font-size: 11px; font-weight: 700; color: var(--white); background: var(--main-bg);
}

/* ============================================
 * Tabs
 * ============================================ */
.tabs {
    display: flex; background: var(--gray-100); border-radius: var(--radius-md);
    padding: 3px; margin-bottom: var(--space-md); overflow-x: auto;
}
.tab-btn {
    flex: 1; padding: 10px 12px; text-align: center; font-size: var(--font-size-sm);
    font-weight: 600; color: var(--gray-500); border-radius: var(--radius-sm);
    transition: all var(--transition-fast); white-space: nowrap;
}
.tab-btn.active { background: var(--white); color: var(--main-bg); box-shadow: var(--shadow-sm); }
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

/* ============================================
 * List
 * ============================================ */
.list-item {
    display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-md); border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
}
.list-item:active { background: var(--gray-50); }
.list-item:last-child { border-bottom: none; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; }
.list-item-subtitle { font-size: var(--font-size-sm); color: var(--gray-500); margin-top: 2px; }

/* ============================================
 * Table
 * ============================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.data-table th { background: var(--gray-50); font-weight: 600; text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--main-bg); }

/* ============================================
 * Grid & Utilities
 * ============================================ */
.grid { display: grid; gap: var(--space-md); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card { background: var(--white); border-radius: var(--radius-md); padding: var(--space-md); text-align: center; box-shadow: var(--shadow-sm); }
.stat-card .stat-number { font-size: var(--font-size-2xl); font-weight: 800; color: var(--main-bg); }
.stat-card .stat-label { font-size: var(--font-size-xs); color: var(--gray-500); margin-top: 4px; }

.avatar {
    width: 40px; height: 40px; border-radius: var(--radius-full);
    background: var(--main-bg-light); display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--main-bg); font-size: var(--font-size-sm); flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }

.empty-state { text-align: center; padding: var(--space-2xl) var(--space-md); color: var(--gray-500); }
.empty-state-icon { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.5; }

.loading-spinner { display: flex; align-items: center; justify-content: center; padding: var(--space-xl); }
.loading-spinner::after {
    content: ''; width: 32px; height: 32px; border: 3px solid var(--gray-200);
    border-top-color: var(--main-bg); border-radius: var(--radius-full); animation: spin 0.8s linear infinite;
}
.loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500;
    display: flex; align-items: flex-end; justify-content: center; animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--white); width: 100%; max-width: 480px; max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow-y: auto; animation: slideUp 0.3s ease;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-lg) var(--space-md) var(--space-md); position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-title { font-size: var(--font-size-lg); font-weight: 700; }
.modal-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); font-size: 20px; color: var(--gray-500); }
.modal-body { padding: 0 var(--space-md) var(--space-lg); }

/* Divider */
.divider { height: 1px; background: var(--gray-200); margin: var(--space-md) 0; }

/* ============================================
 * Utility Classes
 * ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.text-bold { font-weight: 700; }
.text-primary { color: var(--main-bg); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.items-center { align-items: center; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.p-md { padding: var(--space-md); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Chart (coaching chart) */
.chart-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.chart-cell {
    aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all var(--transition-fast);
}
.chart-cell:active { transform: scale(0.95); }
.chart-cell.normal { background: #E8F5E9; color: #2E7D32; }
.chart-cell.no_submit { background: var(--gray-100); color: var(--gray-500); }
.chart-cell.warning_5pm { background: #FFF3E0; color: #E65100; }
.chart-cell.delay_6pm { background: #FFEBEE; color: #C62828; }
.chart-cell.pending { background: var(--gray-50); color: var(--gray-400); border: 1px dashed var(--gray-300); }
.chart-cell.skipped { background: var(--gray-200); color: var(--gray-500); text-decoration: line-through; }

/* ============================================
 * Animations
 * ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-slideDown { animation: slideDown 0.3s ease; }

/* ============================================
 * Responsive (PC)
 * ============================================ */
@media (min-width: 768px) {
    body { background: var(--gray-200); }
    .app-container { box-shadow: var(--shadow-lg); }
    .modal-backdrop { align-items: center; }
    .modal { border-radius: var(--radius-xl); max-height: 80vh; }
}
