/* ===== 기본 리셋 및 변수 ===== */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    --text-color: #2d3748;
    --text-light: #718096;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* ===== 헤더 ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    margin: 0 -16px 20px;
    color: white;
}

.header-content {
    text-align: left;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.header .subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.history-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    transition: background 0.2s;
}

.history-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== 스텝 인디케이터 ===== */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    padding: 0 8px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
}

.step.active .step-number,
.step.completed .step-number {
    background: var(--primary-color);
    color: white;
}

.step.completed .step-number {
    background: var(--success-color);
}

.step-label {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
}

.step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 8px 20px;
    max-width: 40px;
}

/* ===== 메인 컨텐츠 ===== */
.main-content {
    position: relative;
}

.step-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step-content.active {
    display: block;
}

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

.step-content h2 {
    font-size: 20px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-color);
}

.instruction {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ===== 카메라 컨테이너 ===== */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #1a202c;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.face-overlay {
    pointer-events: none;
    transform: scaleX(-1);
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 280px;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
}

/* ===== 캡처 프리뷰 ===== */
.capture-preview {
    position: relative;
    margin-bottom: 16px;
}

.capture-preview img {
    width: 100%;
    border-radius: 16px;
    display: block;
}

.btn-retake {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}

/* ===== 버튼 ===== */
.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

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

.btn-icon {
    font-size: 20px;
}

/* ===== 분석 결과 ===== */
.analysis-result {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}

.analysis-result h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-color);
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.score-item {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 12px;
}

.score-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.score-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.score-bar-fill.excellent {
    background: var(--success-color);
}

.score-bar-fill.good {
    background: var(--primary-color);
}

.score-bar-fill.average {
    background: var(--warning-color);
}

.score-bar-fill.poor {
    background: var(--danger-color);
}

/* ===== 화장품 사용 안내 ===== */
.cosmetic-guide {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.guide-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.cosmetic-guide p {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 20px;
}

.guide-list {
    text-align: left;
    list-style: none;
    padding: 0;
}

.guide-list li {
    padding: 8px 0;
    padding-left: 28px;
    position: relative;
    color: var(--text-light);
    font-size: 14px;
}

.guide-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

/* ===== 결과 비교 ===== */
.comparison-container {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.comparison-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.comparison-item {
    position: relative;
}

.comparison-item img {
    width: 100%;
    border-radius: 12px;
    display: block;
}

.comparison-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.improvement-summary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.improvement-rate {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.improvement-label {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 4px;
}

.comparison-table {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.comparison-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.comparison-row:last-child {
    border-bottom: none;
}

.comparison-row .label {
    flex: 1;
    font-size: 14px;
    color: var(--text-color);
}

.comparison-row .before,
.comparison-row .after {
    width: 50px;
    text-align: center;
    font-weight: 600;
}

.comparison-row .change {
    width: 70px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
}

.change.positive {
    color: var(--success-color);
}

.change.negative {
    color: var(--danger-color);
}

.change.neutral {
    color: var(--text-light);
}

/* ===== 로딩 오버레이 ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: var(--text-color);
    font-size: 16px;
}

/* ===== 토스트 메시지 ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ===== 유틸리티 ===== */
.hidden {
    display: none !important;
}

/* ===== 반응형 ===== */
@media (max-width: 360px) {
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .step-label {
        font-size: 10px;
    }

    .score-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 481px) {
    #app {
        padding-top: 20px;
    }

    .header {
        border-radius: 0 0 24px 24px;
    }
}
