/* ═══════════════════════════════════════════════
   mobile.css — 모바일 제품 등록 전용 스타일
   ═══════════════════════════════════════════════ */

:root {
    --m-bg: #0f172a;
    --m-surface: #1e293b;
    --m-surface-2: #334155;
    --m-border: #475569;
    --m-text: #f1f5f9;
    --m-text-dim: #94a3b8;
    --m-primary: #6366f1;
    --m-primary-glow: rgba(99, 102, 241, 0.3);
    --m-success: #10b981;
    --m-warning: #f59e0b;
    --m-danger: #ef4444;
    --m-radius: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--m-bg);
    color: var(--m-text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── 헤더 ── */
.m-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.m-header-title {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, #818cf8, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.m-header-badge {
    font-size: 10px;
    background: var(--m-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
}

/* ── 카메라 영역 ── */
.m-camera-section {
    position: relative;
    background: #000;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 55vh;
    overflow: hidden;
    border-bottom: 2px solid var(--m-primary);
}

.m-camera-section video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.m-camera-section canvas {
    display: none;
}

.m-camera-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
}

.m-camera-guide {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 60%;
    border: 2px solid rgba(99, 102, 241, 0.6);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.m-camera-guide::before {
    content: '택을 사각형 안에 맞춰주세요';
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
}

.m-camera-status {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.m-camera-status .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--m-danger);
    animation: pulse-dot 1.5s infinite;
}

.m-camera-status.scanning .dot { background: var(--m-success); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── 촬영 버튼 영역 ── */
.m-camera-controls {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.m-btn-capture {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.m-btn-capture::after {
    content: '';
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border-radius: 50%;
    background: #fff;
    transition: all 0.15s;
}

.m-btn-capture:active::after {
    background: var(--m-primary);
    transform: scale(0.85);
}

.m-btn-mode {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.m-btn-mode.active {
    border-color: var(--m-primary);
    background: var(--m-primary-glow);
    color: var(--m-primary);
}

/* ── 미리보기 (촬영 후) ── */
.m-preview-section {
    display: none;
    position: relative;
    background: #000;
    width: 100%;
    max-height: 40vh;
}

.m-preview-section img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.m-preview-actions {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
}

.m-preview-badge {
    position: absolute;
    top: 8px; left: 8px;
    background: var(--m-primary);
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

/* ── 촬영 결과 썸네일 바 ── */
.m-thumbnails {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: var(--m-surface);
    border-bottom: 1px solid var(--m-border);
}

.m-thumb {
    position: relative;
    width: 56px; height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    flex-shrink: 0;
    cursor: pointer;
}

.m-thumb.active { border-color: var(--m-primary); }

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

.m-thumb-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.7);
    font-size: 8px;
    text-align: center;
    padding: 1px 0;
    color: #fff;
    font-weight: 600;
}

.m-thumb-remove {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--m-danger);
    color: #fff;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── OCR 분석 결과 ── */
.m-ocr-result {
    margin: 12px 16px;
    padding: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--m-radius);
    display: none;
}

.m-ocr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.m-ocr-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--m-primary);
}

.m-ocr-confidence {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

.m-ocr-confidence.high { background: rgba(16,185,129,0.15); color: var(--m-success); }
.m-ocr-confidence.medium { background: rgba(245,158,11,0.15); color: var(--m-warning); }
.m-ocr-confidence.low { background: rgba(239,68,68,0.15); color: var(--m-danger); }

.m-ocr-tag-type {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    display: inline-block;
    margin-top: 4px;
}

.m-ocr-tag-type.full { background: rgba(16,185,129,0.15); color: var(--m-success); }
.m-ocr-tag-type.partial { background: rgba(245,158,11,0.15); color: var(--m-warning); }
.m-ocr-tag-type.empty { background: rgba(239,68,68,0.15); color: var(--m-danger); }

/* ── 등록 폼 ── */
.m-form {
    padding: 16px;
}

.m-form-title {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.m-field {
    margin-bottom: 10px;
}

.m-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--m-text-dim);
    margin-bottom: 4px;
}

.m-field input,
.m-field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: 8px;
    color: var(--m-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.m-field input:focus,
.m-field select:focus {
    border-color: var(--m-primary);
    box-shadow: 0 0 0 3px var(--m-primary-glow);
}

.m-field input.ocr-filled {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.05);
}

.m-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.m-field-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* ── 브랜드 자동완성 ── */
.m-brand-suggest {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.m-brand-item {
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(71,85,105,0.3);
}

.m-brand-item:hover, .m-brand-item:active {
    background: var(--m-primary-glow);
}

/* ── 하단 고정 버튼 ── */
.m-bottom-bar {
    position: sticky;
    bottom: 0;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--m-border);
    display: flex;
    gap: 10px;
}

.m-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.m-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.m-btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.m-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.m-btn-secondary {
    background: var(--m-surface);
    color: var(--m-text-dim);
    border: 1px solid var(--m-border);
}

/* ── 로딩 오버레이 ── */
.m-loading {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.m-loading.show { display: flex; }

.m-loading-spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--m-surface-2);
    border-top-color: var(--m-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.m-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--m-text-dim);
}

/* ── 토스트 ── */
.m-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    z-index: 1000;
    transition: transform 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.m-toast.show { transform: translateX(-50%) translateY(0); }
.m-toast.success { background: var(--m-success); color: #fff; }
.m-toast.error { background: var(--m-danger); color: #fff; }
.m-toast.info { background: var(--m-primary); color: #fff; }

/* ── 성공 화면 ── */
.m-success-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

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

.m-success-sku {
    font-size: 24px;
    font-weight: 900;
    color: var(--m-primary);
    margin-bottom: 8px;
}

.m-success-name {
    font-size: 14px;
    color: var(--m-text-dim);
    margin-bottom: 32px;
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--m-surface-2); border-radius: 4px; }
