/* =========================================================================
   V2 GRUNDBASIS - GLOBALES DESIGN SYSTEM
   Pfad: public/assets/css/styles.css
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. SEMANTISCHE VARIABLEN (Theme-Konfiguration)
   ------------------------------------------------------------------------- */
:root {
    /* Farbpalette: Primär & Sekundär (Ersetzt alte CI-Farben) */
    --color-primary: #0f172a;        /* Dunkelblau / Slate 900 */
    --color-primary-light: #1e293b;
    --color-secondary: #0ea5e9;      /* Modernes Türkis/Cyan */
    --color-secondary-dark: #0284c7;

    /* Hintergrund & Flächen */
    --color-bg: #f1f5f9;             /* App-Hintergrund */
    --color-surface: #ffffff;        /* Karten & Panels */
    
    /* Textfarben */
    --color-text-main: #334155;      /* Haupt-Text */
    --color-text-muted: #64748b;     /* Untertitel & Meta-Infos */
    --color-text-light: #94a3b8;     /* Platzhalter */
    
    /* Rahmen & Linien */
    --color-border: #e2e8f0;
    --color-border-focus: #94a3b8;

    /* Status-Farben (Alerts & Badges) */
    --color-success: #10b981;
    --color-success-bg: #d1fae5;
    --color-error: #ef4444;
    --color-error-bg: #fee2e2;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef3c7;
    --color-info: #3b82f6;
    
    /* Typografie */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', ui-monospace, monospace;
    
    /* Schatten & Radien */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 15px rgba(14, 165, 233, 0.3);
}

/* -------------------------------------------------------------------------
   2. RESET & BASIS-TYPOGRAFIE
   ------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-primary);
    font-weight: 700;
    line-height: 1.2;
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-secondary-dark);
}

/* -------------------------------------------------------------------------
   3. LAYOUT & STRUKTUR
   ------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.page-header-bordered {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
    animation: fadeInDown 0.4s ease-out forwards;
}

.page-title {
    font-size: 28px;
    margin-bottom: 5px;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Standard CSS-Grid für Master-Detail Ansichten (Formular links, Tabelle rechts) */
.layout-grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 900px) {
    .layout-grid-sidebar {
        grid-template-columns: 1fr; /* Bricht auf Mobile untereinander um */
    }
    .page-header-bordered {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

/* -------------------------------------------------------------------------
   4. KARTEN & PANELS (Cards)
   ------------------------------------------------------------------------- */
.form-card, .table-card, .panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: var(--shadow-md);
}

/* Spezielle Akzent-Karte (z.B. für Formulare) */
.form-card {
    border-top: 4px solid var(--color-secondary);
}

.form-card-title {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
}

/* -------------------------------------------------------------------------
   5. FORMULARE & INPUTS
   ------------------------------------------------------------------------- */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 13px;
    color: var(--color-text-main);
    font-weight: 600;
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text-main);
    font-family: var(--font-main);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); /* Soft-Glow im Sekundär-Farbton */
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* -------------------------------------------------------------------------
   6. BUTTONS
   ------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    text-decoration: none;
    font-family: var(--font-main);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Standard / Primary Button */
.btn, .btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
}

.btn:hover, .btn-primary:hover {
    background-color: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

/* Secondary Button (Aktion) */
.btn-secondary {
    background-color: var(--color-secondary);
    color: #ffffff;
}

.btn-secondary:hover {
    background-color: var(--color-secondary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Outline / Cancel Button */
.btn-outline {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text-main);
}

.btn-outline:hover {
    background-color: var(--color-bg);
    border-color: var(--color-border-focus);
    transform: translateY(-1px);
}

/* Roter Button / Delete */
.btn-danger {
    background-color: var(--color-error);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Icon-Button für Tabellen */
.btn-contract-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: all 0.2s;
    color: var(--color-text-muted);
}

.btn-contract-icon:hover {
    background-color: var(--color-bg);
    color: var(--color-primary);
    transform: scale(1.1);
}

/* -------------------------------------------------------------------------
   7. TABELLEN (Datenansicht)
   ------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
}

/* Rückwärtskompatibilität zum Blueprint (.cdu-table) und neuer Standard (.data-table) */
.cdu-table, .data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.cdu-table th, .data-table th {
    padding: 12px 15px;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cdu-table td, .data-table td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    color: var(--color-text-main);
    transition: background-color 0.2s;
}

.cdu-table tr:last-child td, .data-table tr:last-child td {
    border-bottom: none;
}

.cdu-table tbody tr:hover td, .data-table tbody tr:hover td {
    background-color: rgba(14, 165, 233, 0.05); /* Leichter Akzent beim Hover */
}

/* Mono-Font für IDs und technische Daten in Tabellen */
.td-mono {
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    font-size: 13px;
}

/* Responsive Tabellen für Mobile (Manager) */
@media (max-width: 768px) {
    .data-table, .data-table thead, .data-table tbody, .data-table th, .data-table td, .data-table tr {
        display: block;
    }
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .data-table tr {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        margin-bottom: 15px;
        padding: 10px;
        background: var(--color-surface);
    }
    .data-table td {
        border: none;
        border-bottom: 1px solid var(--color-bg);
        position: relative;
        padding-left: 45%;
        text-align: left;
    }
    .data-table td:last-child {
        border-bottom: 0;
    }
    .data-table td::before {
        position: absolute;
        top: 14px;
        left: 10px;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 700;
        color: var(--color-text-muted);
        font-size: 12px;
        text-transform: uppercase;
    }
    .data-table td:nth-of-type(1)::before { content: "Deutsch:"; }
    .data-table td:nth-of-type(2)::before { content: "Fremdsprache:"; }
    .data-table td:nth-of-type(3)::before { content: "Aussprache:"; }
    .data-table td:nth-of-type(4)::before { content: "Kategorie:"; }
    .data-table td:nth-of-type(5)::before { display: none; }
    .data-table td:nth-of-type(5) {
        padding-left: 0;
        text-align: center;
        margin-top: 10px;
    }
}

/* -------------------------------------------------------------------------
   8. ALERTS & NOTIFICATIONS
   ------------------------------------------------------------------------- */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid;
    animation: fadeInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.alert-success {
    background-color: var(--color-success-bg);
    color: #065f46;
    border-left-color: var(--color-success);
}

.alert-error {
    background-color: var(--color-error-bg);
    color: #991b1b;
    border-left-color: var(--color-error);
}

.alert-warning {
    background-color: var(--color-warning-bg);
    color: #92400e;
    border-left-color: var(--color-warning);
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left-color: var(--color-info);
}

/* -------------------------------------------------------------------------
   9. BADGES & LABELS
   ------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* -------------------------------------------------------------------------
   10. MODALS & OVERLAYS (Manager)
   ------------------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out forwards;
}

/* -------------------------------------------------------------------------
   11. AUTHENTIFIZIERUNG (Login)
   ------------------------------------------------------------------------- */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--color-primary); /* Dunkler Hintergrund für Login */
    background-image: radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 400px);
}

.login-box {
    background: var(--color-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 350px;
    text-align: center;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* -------------------------------------------------------------------------
   12. DASHBOARD SPEZIFISCH
   ------------------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* -------------------------------------------------------------------------
   13. ANIMATIONS, TRANSITIONS & UX POLISH (Global Core)
   ------------------------------------------------------------------------- */

/* Keyframes */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pulsierender Hover für Interleaved / Flow-State Buttons */
@keyframes pulseWarning {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulsePrimary {
    0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(14, 165, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

/* Globale Animations-Klassen */
.animate-slide-up {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Hilfsklassen für Buttons um Attention zu generieren (z.B. Interleaved Sprint Button im Dashboard) */
.btn-pulse-warning {
    animation: pulseWarning 2s infinite;
}
.btn-pulse-warning:hover {
    animation: none;
    transform: scale(1.02);
}

.btn-pulse-primary {
    animation: pulsePrimary 2s infinite;
}
.btn-pulse-primary:hover {
    animation: none;
    transform: scale(1.02);
}

/* Globale Scrollbar-Optimierung (Für saubere Sidebars und Modals) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg); 
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-focus); 
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted); 
}

/* -------------------------------------------------------------------------
   14. ELITE-NUMPAD & SPRINT-FLOW (Mental Math Engine)
   ------------------------------------------------------------------------- */
.elite-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 350px;
    margin: 20px auto 0;
}

.numpad-btn {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    color: var(--color-primary);
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-mono);
    border-radius: var(--radius-md);
    padding: 18px 0;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.05s ease, background-color 0.1s, border-color 0.1s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Hardware-beschleunigtes mechanisches Feedback */
.numpad-btn:active {
    transform: scale(0.92);
    background-color: var(--color-bg);
    border-color: var(--color-secondary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.numpad-btn-del {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: rgba(239, 68, 68, 0.3);
}

@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.animate-shake {
    animation: screenShake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

/* Fovealer Tunnelblick für extremen Flow / Combo-State */
body.tunnel-vision::after {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 9999;
    animation: fadeIn 0.5s ease-out forwards;
}

/* Floating Time Animations (Phase 3: Sudden Death) */
.float-time {
    position: absolute;
    font-size: 24px;
    font-weight: 800;
    pointer-events: none;
    animation: floatUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    z-index: 100;
}
.float-plus { color: var(--color-success); text-shadow: 0 2px 4px rgba(16,185,129,0.3); }
.float-minus { color: var(--color-error); text-shadow: 0 2px 4px rgba(239,68,68,0.3); }

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.2); }
}

/* Ghost Bar (Phase 3: Asynchronous Racing) */
.ghost-track-container {
    width: 100%;
    height: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--color-border);
}
.ghost-track-fill {
    height: 100%;
    background: rgba(142, 68, 173, 0.6);
    width: 0%;
    transition: width 0.1s linear;
}