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

:root {
    --color-bg: #FFFFFF;
    --color-bg-alt: #F8F9FA;
    --color-text: #1A1A2E;
    --color-text-muted: #555;
    --color-primary: #2563EB;
    --color-primary-hover: #1D4ED8;
    --color-error: #DC2626;
    --color-success: #059669;
    --color-warning: #D97706;
    --color-info: #2563EB;
    --color-border: #D1D5DB;
    --color-border-focus: #2563EB;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

h1, h2, h3, h4 { line-height: 1.3; margin-bottom: 0.5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

/* === WCAG: Skip-Link === */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--color-text);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 1000;
    text-decoration: underline;
}
.skip-link:focus { top: 0; }

/* === WCAG: Screen-Reader Only === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Navigation === */
nav[aria-label="Hauptnavigation"] {
    background: var(--color-text);
    color: #fff;
    padding: 0 1rem;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
    min-height: 56px;
    flex-wrap: wrap;
}
.nav-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
}
.nav-links {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    flex: 1;
}
.nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    display: inline-block;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
    color: #fff;
    background: rgba(255,255,255,0.15);
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255,255,255,0.85);
}
.nav-user a { color: rgba(255,255,255,0.85); }

/* === Flash Messages === */
.flash-container { margin-bottom: 1.5rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border-left: 4px solid;
}
.flash-error { background: #FEF2F2; border-color: var(--color-error); color: #991B1B; }
.flash-success { background: #F0FDF4; border-color: var(--color-success); color: #166534; }
.flash-info { background: #EFF6FF; border-color: var(--color-info); color: #1E40AF; }
.flash-warning { background: #FFFBEB; border-color: var(--color-warning); color: #92400E; }

/* === Forms === */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group .help-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}
.form-group .error-text {
    font-size: 0.875rem;
    color: var(--color-error);
    margin-top: 0.25rem;
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.slider-container input[type="range"] { flex: 1; }
.slider-container input[type="number"] { width: 80px; }

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    min-height: 44px;
    min-width: 44px;
}
.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-secondary {
    background: var(--color-bg-alt);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover { background: #E5E7EB; }
.btn-danger {
    background: var(--color-error);
    color: #fff;
}
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; min-height: 36px; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* === Cards === */
.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* === Tables === */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}
th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
th {
    font-weight: 600;
    background: var(--color-bg-alt);
}
tbody tr:hover { background: var(--color-bg-alt); }

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* === Mode Cards === */
.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.mode-card {
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.mode-card:hover,
.mode-card.selected {
    border-color: var(--color-primary);
    background: #EFF6FF;
}
.mode-card input[type="radio"] { margin-right: 0.5rem; }
.mode-card h3 { margin-bottom: 0.25rem; }
.mode-card p { font-size: 0.9rem; color: var(--color-text-muted); }

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--color-bg-alt);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.progress-fill {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s ease;
    border-radius: 12px;
}

/* === Script Editor === */
.script-elements { list-style: none; }
.element {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.element-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.element-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-voice { background: #DBEAFE; color: #1E40AF; }
.badge-sfx { background: #FEF3C7; color: #92400E; }
.badge-music { background: #D1FAE5; color: #065F46; }
.badge-song { background: #EDE9FE; color: #5B21B6; }
.element-content textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}
.element-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* === Wizard Steps === */
.wizard-steps {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    counter-reset: step;
}
.wizard-step {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    background: var(--color-bg-alt);
    border-bottom: 3px solid var(--color-border);
    font-size: 0.9rem;
    counter-increment: step;
}
.wizard-step::before {
    content: counter(step) ". ";
    font-weight: 700;
}
.wizard-step.active {
    background: #EFF6FF;
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}
.wizard-step.done {
    background: #F0FDF4;
    border-bottom-color: var(--color-success);
}

/* === Modal Dialog === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

/* === Badge / Status === */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-draft { background: #E5E7EB; color: #374151; }
.status-generating { background: #DBEAFE; color: #1E40AF; }
.status-ready { background: #FEF3C7; color: #92400E; }
.status-completed { background: #D1FAE5; color: #065F46; }
.status-failed { background: #FEE2E2; color: #991B1B; }

/* === Spinner === */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Footer === */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* === Auth Page === */
.auth-container {
    max-width: 440px;
    margin: 3rem auto;
}
.auth-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* === Responsive === */
@media (max-width: 768px) {
    .nav-container { flex-direction: column; padding: 0.75rem 0; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .mode-cards { grid-template-columns: 1fr; }
}
