/* SAFE-T Eingabetool — Hauptstylesheet */

:root {
    --color-bg: #f5f5f7;
    --color-surface: #ffffff;
    --color-border: #e0e0e4;
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-primary: #0066cc;
    --color-primary-hover: #004999;
    --color-success: #248a3d;
    --color-success-bg: #e8f5e9;
    --color-error: #d32f2f;
    --color-error-bg: #fce4ec;
    --color-warning: #f57c00;
    --color-warning-bg: #fff3e0;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 180ms ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- App Layout --- */
.app {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

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

.app-header h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--color-border);
    color: var(--color-text-secondary);
}

.header-badge.active {
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* --- Cards --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: opacity var(--transition);
}

.card.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 0;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-body {
    padding: 14px 18px 18px;
}

/* --- Inputs --- */
.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

input, select, textarea {
    font-family: var(--font);
    font-size: 14px;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

.input-lg { flex: 1; font-size: 15px; padding: 10px 14px; font-family: monospace; }
.input-sm { width: 90px; text-align: right; }
.select-lg { width: 100%; font-size: 14px; padding: 10px 14px; }
.textarea { width: 100%; resize: vertical; margin-top: 10px; min-height: 80px; }

/* --- Buttons --- */
.btn {
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { background: #aac8e8; cursor: not-allowed; }

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: #eaeaee; }

.btn-lg { font-size: 15px; padding: 12px 24px; }

/* --- Result Box --- */
.result-box {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
}

.result-box.success {
    background: var(--color-success-bg);
    border: 1px solid #a5d6a7;
}

.result-box.error {
    background: var(--color-error-bg);
    border: 1px solid #ef9a9a;
    color: var(--color-error);
}

.result-box.warning {
    background: var(--color-warning-bg);
    border: 1px solid #ffcc80;
    color: var(--color-warning);
}

/* --- Berechnung --- */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
    margin: 8px 0;
    font-size: 13px;
}

.calc-grid .label { color: var(--color-text-secondary); }
.calc-grid .value { text-align: right; font-variant-numeric: tabular-nums; }
.calc-grid .total { font-weight: 700; font-size: 15px; color: var(--color-primary); border-top: 1px solid var(--color-border); padding-top: 6px; margin-top: 4px; }

/* --- Photo Grid --- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.photo-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition);
}

.photo-item.selected { border-color: var(--color-primary); }

.photo-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.photo-item .photo-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 11px;
    padding: 3px 6px;
    text-align: center;
}

.photo-item .photo-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all var(--transition);
}

.photo-item.selected .photo-check {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* --- Photo Status (waiting) --- */
.photo-status { text-align: center; padding: 20px 0; }

.waiting-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 6px;
}

/* --- Summary Row --- */
.summary-row {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.summary-item {
    font-size: 13px;
}

.summary-item .label {
    color: var(--color-text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-item .value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* --- Text Counter --- */
.text-counter {
    text-align: right;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.text-counter.over { color: var(--color-error); font-weight: 600; }

/* --- Action Row --- */
.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    gap: 10px;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: opacity 300ms;
}

.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: var(--color-error); }
.toast.success { background: var(--color-success); }

/* --- Utilities --- */
.hidden { display: none !important; }

/* --- Spinner (loading state for button) --- */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}
.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
