/* ============================================
   GESICHTSANALYSE — Ready2Change.NOW
   Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
    --purple: #5C3282;
    --purple-light: #F3EEF8;
    --purple-dark: #3D1F5C;
    --orange: #C04B00;
    --orange-light: #FFF3EB;
    --navy: #1A1A4E;
    --teal: #1A5F6A;
    --teal-light: #E8F4F6;
    --green: #2D8B4E;
    --green-light: #EBF7EF;
    --gold: #F4A53F;
    --gold-light: #FFF8ED;
    --red: #C0392B;
    --red-light: #FDEDEB;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Header --- */
#app-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--purple-dark) 100%);
    color: white;
    text-align: center;
    padding: 24px 16px 0;
}

#app-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

#app-header .subtitle {
    font-size: 13px;
    opacity: 0.7;
    margin-bottom: 16px;
}

/* --- Navigation Tabs --- */
#nav-tabs {
    display: flex;
    gap: 2px;
    justify-content: center;
    padding: 0 16px;
}

.nav-tab {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.6);
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: var(--transition);
}

.nav-tab:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-tab.active { background: var(--gray-50); color: var(--purple); font-weight: 600; }
.nav-tab.disabled { opacity: 0.3; cursor: not-allowed; }

/* --- Screens --- */
.screen { padding: 24px 16px 48px; }
.hidden { display: none !important; }

/* --- Panel --- */
.panel {
    max-width: 720px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.panel-wide { max-width: 960px; }

.panel h2 {
    font-size: 22px;
    color: var(--purple);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--purple-light);
}

/* --- Input Groups --- */
.input-group { margin-bottom: 20px; }

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="date"],
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    transition: var(--transition);
    background: white;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(92,50,130,0.1);
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-row input { flex: 1; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--purple); }

/* --- Product Info Cards --- */
.product-info { margin-bottom: 20px; }

.info-card {
    display: none;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
}

.info-card.active { display: block; }
#info-gratis { background: var(--green-light); border-left: 4px solid var(--green); }
#info-starter { background: var(--gold-light); border-left: 4px solid var(--gold); }
#info-deep { background: var(--purple-light); border-left: 4px solid var(--purple); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-secondary {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-100); }

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover { background: #A93226; }

.btn-large {
    padding: 14px 32px;
    font-size: 16px;
}

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

.button-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* --- Welcome Screen / Mode Cards --- */
.welcome-heading {
    text-align: center;
    border: none !important;
    font-size: 24px;
    margin-bottom: 32px;
}

.mode-cards {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.mode-card {
    flex: 1;
    max-width: 320px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-card:hover {
    border-color: var(--purple);
    box-shadow: 0 8px 24px rgba(92,50,130,0.15);
    transform: translateY(-4px);
}

.mode-card:active {
    transform: translateY(-1px);
}

.mode-icon {
    font-size: 64px;
    margin-bottom: 16px;
    line-height: 1;
}

.mode-card h3 {
    font-size: 20px;
    color: var(--purple);
    margin-bottom: 6px;
}

.mode-card > p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.mode-features {
    list-style: none;
    text-align: left;
    width: 100%;
    margin-bottom: 20px;
}

.mode-features li {
    font-size: 13px;
    color: var(--gray-600);
    padding: 5px 0;
    border-bottom: 1px solid var(--gray-100);
    padding-left: 8px;
}

.mode-features li::before {
    content: '\2713  ';
    color: var(--green);
    font-weight: 700;
}

.mode-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--purple-light);
    color: var(--purple);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

@media (max-width: 640px) {
    .mode-cards { flex-direction: column; align-items: center; }
    .mode-card { max-width: 100%; }
}

/* --- Preparation Checklist --- */
.prep-checklist {
    background: var(--gold-light);
    border: 2px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.prep-checklist h3 {
    color: var(--orange);
    font-size: 16px;
    margin-bottom: 16px;
}

.prep-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.prep-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.prep-item:hover { border-color: var(--gold); }
.prep-item:has(input:checked) { border-color: var(--green); background: var(--green-light); }

.prep-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--green);
    flex-shrink: 0;
    margin-top: 1px;
}

.prep-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prep-text strong {
    font-size: 14px;
    color: var(--gray-800);
    line-height: 1.3;
}

.prep-text span {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.3;
}

.prep-item:has(input:checked) .prep-text strong { color: var(--green); }
.prep-item:has(input:checked) .prep-text span { color: var(--green); opacity: 0.7; }

.prep-note {
    font-size: 12px;
    color: var(--gray-500);
    font-style: italic;
    margin-bottom: 16px;
}

/* --- Step Indicator (Capture) --- */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.step {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-500);
    transition: var(--transition);
}

.step.active { background: var(--purple); color: white; }
.step.done { background: var(--green); color: white; }

/* --- Capture Instruction --- */
.capture-instruction {
    text-align: center;
    padding: 16px;
    background: var(--gold-light);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.instruction-text { font-size: 16px; color: var(--gray-700); }

/* --- Camera --- */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto 20px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--gray-900);
    aspect-ratio: 4/3;
}

#camera-video, #capture-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#camera-canvas { display: none; }

/* --- Video Recording --- */
#video-recording {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--red);
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

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

/* --- Thumbnails --- */
.thumbnails {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    border: 2px solid var(--gray-200);
    cursor: pointer;
    transition: var(--transition);
}

.thumbnail:hover { border-color: var(--purple); }
.thumbnail.active { border-color: var(--purple); box-shadow: 0 0 0 2px rgba(92,50,130,0.3); }

/* --- Progress --- */
.progress-container { margin-bottom: 24px; }

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--purple) 0%, var(--teal) 100%);
    border-radius: 12px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--gray-500);
    text-align: center;
    display: block;
}

/* --- Module List (Analyse) --- */
.module-list { margin-bottom: 20px; }

.module-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    transition: var(--transition);
}

.module-group.running { background: var(--purple-light); }
.module-group.done { opacity: 0.7; }

.module-status { font-size: 18px; width: 24px; text-align: center; }
.module-group.running .module-status::after { content: ''; display: inline-block; width: 16px; height: 16px; border: 2px solid var(--purple); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.module-group.done .module-status { color: var(--green); }

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

.analysis-detail {
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

/* --- Summary Box (Review) --- */
.summary-box {
    background: linear-gradient(135deg, var(--purple-light) 0%, var(--teal-light) 100%);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.summary-box h3 { color: var(--purple); margin-bottom: 12px; font-size: 16px; }

/* --- Review Tabs --- */
.review-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.review-tab {
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.review-tab:hover { border-color: var(--purple); }
.review-tab.active { background: var(--purple); color: white; border-color: var(--purple); }

/* --- Review Content --- */
.review-content {
    min-height: 300px;
    margin-bottom: 24px;
}

.review-panel {
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
}

.review-panel h2 { font-size: 18px; margin-top: 20px; margin-bottom: 8px; border: none; padding: 0; }
.review-panel h3 { font-size: 15px; color: var(--teal); margin-top: 14px; margin-bottom: 6px; }

/* Evidenz Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

.badge-1 { background: var(--green-light); color: var(--green); }
.badge-2 { background: var(--teal-light); color: var(--teal); }
.badge-3 { background: var(--gold-light); color: var(--orange); }
.badge-4 { background: var(--purple-light); color: var(--purple); }

/* --- Chat Section --- */
.chat-section {
    border-top: 1px solid var(--gray-200);
    padding-top: 20px;
    margin-top: 24px;
}

.chat-section h3 { font-size: 15px; color: var(--gray-600); margin-bottom: 12px; }

.chat-messages {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
}

.chat-msg.user { background: var(--purple-light); margin-left: 40px; }
.chat-msg.ai { background: var(--gray-100); margin-right: 40px; }

.chat-input-row { display: flex; gap: 8px; }
.chat-input-row textarea { flex: 1; padding: 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; resize: none; }
.chat-input-row textarea:focus { outline: none; border-color: var(--purple); }

/* --- Export Preview --- */
.export-preview {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.preview-stat {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: var(--purple-light);
    border-radius: var(--radius);
}

.preview-stat strong {
    display: block;
    font-size: 28px;
    color: var(--purple);
    margin-bottom: 4px;
}

/* --- Download Section --- */
.download-section {
    text-align: center;
    padding: 20px;
    background: var(--green-light);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

/* --- Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 640px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 { font-size: 16px; color: var(--purple); }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px 8px;
}

.modal-close:hover { color: var(--gray-800); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
    font-size: 14px;
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    #app-header h1 { font-size: 22px; }
    .panel { padding: 20px; margin: 0 4px; }
    .nav-tab { padding: 8px 12px; font-size: 12px; }
    .export-preview { flex-direction: column; }
    .button-row { flex-direction: column; }
    .btn-large { width: 100%; }
    .review-tabs { gap: 2px; }
    .review-tab { padding: 6px 10px; font-size: 12px; }
}

/* ═══ Customer-Mode: URL kommt aus CRM mit ?mode=&produkt= ═══
   Dev-only-Felder ausblenden, Kunde sieht nur das Noetige. */
html.customer-mode #screen-welcome,
html.customer-mode #screen-setup { display: none !important; }
html.customer-mode #screen-setup .input-group:has(#input-api-key),
html.customer-mode #screen-setup .input-group:has(#select-product),
html.customer-mode #screen-setup #product-info,
html.customer-mode #screen-setup .input-group:has(#input-birthdate),
html.customer-mode #screen-setup .input-group:has(#input-logo),
html.customer-mode #screen-setup .input-group:has(#input-extra),
html.customer-mode #screen-setup #server-key-banner { display: none !important; }

/* Setup-Tab in der Nav-Leiste ausblenden im Customer-Mode */
html.customer-mode #nav-tabs .nav-tab[data-screen="setup"] { display: none !important; }
