/* DermaTrack - Mobile-first styles */
:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface2: #222244;
    --primary: #4a9eff;
    --primary-dark: #2a7edf;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #e8e8f0;
    --text-dim: #8888aa;
    --border: #333355;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
header {
    text-align: center;
    padding: 16px 0 8px;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#stats-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-weight: 700;
    color: var(--text);
}

/* Navigation */
nav {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    margin: 8px 0 16px;
}

.nav-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Hints */
.hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    margin: 8px 0;
}

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 20px;
    line-height: 1.6;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 12px;
}

/* Mole Cards */
.mole-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.15s;
    border-left: 4px solid var(--success);
}

.mole-card:active {
    transform: scale(0.98);
}

.mole-card.risk-moderate {
    border-left-color: var(--warning);
}

.mole-card.risk-high, .mole-card.risk-very_high {
    border-left-color: var(--danger);
}

.mole-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.mole-card-name {
    font-weight: 600;
    font-size: 15px;
}

.mole-card-risk {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
}

.risk-low { background: #22c55e22; color: var(--success); }
.risk-moderate { background: #f59e0b22; color: var(--warning); }
.risk-high { background: #ef444422; color: var(--danger); }
.risk-very_high { background: #ef444444; color: var(--danger); }

.mole-card-info {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

/* Body Map */
.bodymap-controls {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 12px;
}

.toggle-btn {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
}

.toggle-btn.active {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--primary);
}

#bodymap-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    aspect-ratio: 1/2;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

#bodymap-container svg {
    width: 100%;
    height: 100%;
}

.mole-marker {
    cursor: pointer;
    transition: transform 0.15s;
}

.mole-marker:hover {
    transform: scale(1.3);
}

/* Dialog */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.dialog-content {
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
}

.dialog-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.dialog-buttons button {
    flex: 1;
}

/* Camera / Capture */
#camera-container, .camera-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

#camera-video, #bulk-camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.camera-circle {
    width: 70%;
    height: 70%;
    border: 2px dashed rgba(74, 158, 255, 0.4);
    border-radius: 50%;
}

.camera-settings {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 10px 0;
    flex-wrap: wrap;
}

.setting-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
}

.setting-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.camera-controls {
    display: flex;
    justify-content: center;
    padding: 12px;
}

.btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    background: transparent;
    cursor: pointer;
    position: relative;
}

.btn-capture::after {
    content: '';
    position: absolute;
    top: 6px; left: 6px; right: 6px; bottom: 6px;
    background: var(--primary);
    border-radius: 50%;
    transition: transform 0.15s;
}

.btn-capture:active::after {
    transform: scale(0.85);
}

.capture-area {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
}

.btn-capture-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 48px;
    background: var(--surface);
    border: 2px dashed var(--primary);
    border-radius: 16px;
    color: var(--primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.capture-icon {
    font-size: 48px;
}

/* Preview */
#preview-img {
    width: 100%;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.preview-controls {
    display: flex;
    gap: 10px;
}

.preview-controls button {
    flex: 1;
}

/* Loading */
#scan-loading {
    text-align: center;
    padding: 40px;
}

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

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

/* Results */
.results-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.results-risk {
    font-size: 28px;
    font-weight: 800;
}

.results-label {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
}

.score-bar-container {
    margin-bottom: 12px;
}

.score-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
}

.score-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

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

.score-low .score-bar-fill { background: var(--success); }
.score-medium .score-bar-fill { background: var(--warning); }
.score-high .score-bar-fill { background: var(--danger); }

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

.results-images img {
    width: 100%;
    border-radius: 8px;
}

.results-detail {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}

.results-colors {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.color-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--surface2);
}

.results-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.results-actions button {
    flex: 1;
}

/* Detail view */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.detail-name {
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 1px dashed var(--text-dim);
    padding-bottom: 2px;
}

.scan-history-item {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    cursor: pointer;
}

.scan-history-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
}

.scan-history-info {
    flex: 1;
}

.scan-history-date {
    font-size: 12px;
    color: var(--text-dim);
}

.scan-history-risk {
    font-weight: 700;
    font-size: 14px;
}

/* Evolution chart */
.evolution-chart {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.chart-canvas {
    width: 100%;
    height: 200px;
}

/* Scan select */
.scan-mole-item {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scan-mole-item:active {
    background: var(--surface2);
}

/* Footer */
footer {
    padding: 20px 0;
    text-align: center;
}

.disclaimer {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    opacity: 0.6;
}

/* Delete button */
.btn-delete {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}
