/* ============================================
 * 소리튠 주니어 영어학교 - 공통 CSS
 * 리셋, CSS변수, 공통 컴포넌트
 * ============================================ */

/* CSS Variables */
:root {
    --main-bg: #FF7E17;
    --main-bg-dark: #E66E10;
    --coin-badge: #F5B422;
    --coin-number: #F5A623;
    --gold: #FFD700;
    --silver: #C0C0C0;
    --bronze: #CD7F32;

    /* Card colors */
    --card-steady: #4CAF50;
    --card-leader: #2196F3;
    --card-mission: #FF9800;
    --card-posture: #9C27B0;
    --card-passion: #F44336;

    /* 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;

    /* 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;
    --transition-slow: 0.5s 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;
    -moz-osx-font-smoothing: grayscale;
    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;
    -webkit-user-select: none;
    user-select: none;
}

ul, ol {
    list-style: none;
}

/* ============================================
 * 레이아웃
 * ============================================ */

.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 .back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--white);
    font-size: var(--font-size-sm);
    padding: 8px;
    margin: -8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.app-header .back-btn:active {
    background: rgba(255,255,255,0.15);
}

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

.app-footer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 8px 16px calc(var(--safe-bottom) + 8px);
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.app-footer .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    transition: color var(--transition-fast);
}

.app-footer .nav-item.active {
    color: var(--main-bg);
}

.app-footer .nav-item svg {
    width: 24px;
    height: 24px;
}

/* ============================================
 * 공통 컴포넌트
 * ============================================ */

/* 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: #F44336;
    color: var(--white);
}

.btn-success {
    background: #4CAF50;
    color: var(--white);
}

/* 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;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.tag-class {
    background: rgba(255, 126, 23, 0.12);
    color: var(--main-bg);
}

.tag-coach {
    background: rgba(33, 150, 243, 0.12);
    color: var(--card-leader);
}

.tag-other {
    background: rgba(158, 158, 158, 0.12);
    color: var(--gray-600);
}

/* Coin Badge */
.coin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--coin-badge);
    color: var(--white);
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    font-weight: 800;
    font-size: var(--font-size-md);
}

.coin-badge .coin-icon {
    width: 20px;
    height: 20px;
    background: var(--white);
    color: var(--coin-badge);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
}

.coin-badge .coin-number {
    color: var(--white);
    font-size: var(--font-size-lg);
}

.coin-badge-lg {
    padding: 8px 20px;
    font-size: var(--font-size-xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.coin-badge-lg .coin-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
}

.coin-badge-lg .coin-number {
    font-size: var(--font-size-2xl);
}

/* Trophy */
.trophy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 18px;
}

.trophy-gold { color: var(--gold); }
.trophy-silver { color: var(--silver); }
.trophy-bronze { color: var(--bronze); }

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--gray-600);
    font-size: var(--font-size-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }

/* Input */
.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);
}

/* Grid */
.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); }

/* 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;
    font-size: var(--font-size-md);
}

.list-item-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-top: 2px;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: var(--space-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.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;
    min-width: fit-content;
}

.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;
}

/* Empty State */
.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;
}

.empty-state-text {
    font-size: var(--font-size-md);
}

/* Loading */
.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;
}

/* Badge */
.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);
}

/* ============================================
 * 유틸리티
 * ============================================ */
.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-xl { font-size: var(--font-size-xl); }
.text-bold { font-weight: 700; }
.text-orange { color: var(--main-bg); }
.text-white { color: var(--white); }
.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); }
.gap-lg { gap: var(--space-lg); }
.items-center { align-items: center; }

.mt-xs { margin-top: var(--space-xs); }
.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%; }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* ============================================
 * 애니메이션
 * ============================================ */
@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); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-slideUp { animation: slideUp 0.3s ease; }
.animate-slideDown { animation: slideDown 0.3s ease; }
.animate-bounce { animation: bounce 1s ease infinite; }
.animate-pulse { animation: pulse 2s ease infinite; }

/* ============================================
 * Checkbox custom (checklist)
 * ============================================ */
.checkbox-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-wrapper input:checked + .checkbox-custom {
    background: var(--main-bg);
    border-color: var(--main-bg);
}

.checkbox-wrapper input:checked + .checkbox-custom::after {
    content: '✓';
    color: var(--white);
    font-size: 14px;
    font-weight: 700;
}

/* ============================================
 * 반응형 (PC)
 * ============================================ */
@media (min-width: 768px) {
    body {
        background: var(--gray-200);
    }

    .app-container {
        box-shadow: var(--shadow-lg);
        min-height: 100vh;
    }

    .modal-backdrop {
        align-items: center;
    }

    .modal {
        border-radius: var(--radius-xl);
        max-height: 80vh;
    }
}

@media (min-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
