/**
 * STYLESHEET
 * 
 * Styling für die Schullaufbahn Digital Webapp
 */

/* ============================================================================
   GRUNDLEGENDES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Farbschema - Modernes helles Grün */
    --primary-color: #2d6a4f;
    --secondary-color: #52b788;
    --success-color: #40916c;
    --error-color: #e63946;
    --warning-color: #f77f00;
    --light-bg: #d8f3dc;
    --white: #ffffff;
    --border-color: #95d5b2;
    
    /* Zustandsfarben */
    --gk-belegt-bg: #e8f5e9;
    --gk-belegt-color: #2e7d32;
    --gk-eingebracht-bg: #c8e6c9;
    --gk-eingebracht-color: #1b5e20;
    --lk-bg: #fff9c4;
    --lk-color: #f57f17;
    
    /* Abstände */
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    
    /* Schatten */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #74c69d 0%, #52b788 100%);
    min-height: 100vh;
    padding: var(--spacing-md);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ============================================================================
   HEADER
   ============================================================================ */

header {
    background: linear-gradient(135deg, #2d6a4f 0%, #52b788 100%);
    color: var(--white);
    padding: var(--spacing-lg);
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* ============================================================================
   SEKTIONEN
   ============================================================================ */

.section {
    padding: var(--spacing-lg);
    border-bottom: 2px solid var(--light-bg);
}

.section:last-of-type {
    border-bottom: none;
}

.section h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 3px solid var(--secondary-color);
}

.section h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.pf-group {
    margin-bottom: var(--spacing-md);
}

/* ============================================================================
   EINGABEFELDER
   ============================================================================ */

.input-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-select {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-select:hover {
    border-color: var(--secondary-color);
}

.form-select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-select-special {
    background: #f5f5f5;
    border-color: #9e9e9e;
    font-weight: 600;
}

.form-select-special:hover {
    border-color: #757575;
    background: #eeeeee;
}

.form-select-special:focus {
    border-color: #757575;
    box-shadow: 0 0 0 3px rgba(158, 158, 158, 0.2);
}

.form-select option:disabled {
    color: #ccc;
}

.form-select:disabled {
    background-color: #e0e0e0 !important;
    cursor: not-allowed !important;
    color: #999 !important;
    border-color: #ccc !important;
}

/* ============================================================================
   LEGENDE
   ============================================================================ */

.legend {
    background: var(--light-bg);
    padding: var(--spacing-md);
    border-radius: 8px;
    margin-bottom: var(--spacing-md);
}

.legend h4 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.legend-symbol {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1.3rem;
    font-weight: bold;
}

.legend-symbol.empty {
    background: var(--white);
}

.legend-symbol.gk-belegt {
    background: var(--gk-belegt-bg);
    color: var(--gk-belegt-color);
    border-color: var(--gk-belegt-color);
    position: relative;
}

.legend-symbol.gk-belegt::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%232e7d32" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
}

.legend-symbol.gk-eingebracht {
    background: var(--gk-eingebracht-bg);
    color: var(--gk-eingebracht-color);
    border-color: var(--gk-eingebracht-color);
    position: relative;
}

.legend-symbol.gk-eingebracht::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%231b5e20" stroke-width="2"/><line x1="7" y1="7" x2="17" y2="17" stroke="%231b5e20" stroke-width="2"/><line x1="17" y1="7" x2="7" y2="17" stroke="%231b5e20" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
}

.legend-symbol.lk {
    background: var(--lk-bg);
    color: var(--lk-color);
    border-color: var(--lk-color);
}

.legend-note {
    font-style: italic;
    color: #555;
    margin-top: var(--spacing-sm);
}

/* ============================================================================
   TABELLE
   ============================================================================ */

.table-wrapper {
    overflow-x: auto;
    box-shadow: var(--shadow-md);
    border-radius: 8px;
}

#course-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

#course-table thead {
    background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
    color: var(--white);
}

#course-table th {
    padding: 15px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

#course-table th.fach-col {
    text-align: left;
}

/* Desktop: Breitere Fachspalte */
@media (min-width: 769px) {
    #course-table th.fach-col {
        min-width: 180px;
    }
}

#course-table td {
    padding: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    height: 60px;
    vertical-align: middle;
}

.fach-cell {
    text-align: left !important;
    background: var(--light-bg);
    font-weight: 600;
    color: var(--primary-color);
}

.fach-kuerzel {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-weight: normal;
}

/* Aufgabenfeld-Überschriften */
.af-header-row {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
}

.af-header {
    text-align: left !important;
    padding: 12px 15px !important;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--white);
    background: linear-gradient(135deg, #40916c 0%, #2d6a4f 100%);
    border: none !important;
    letter-spacing: 0.5px;
}

.af-header.sport-header {
    background: linear-gradient(135deg, #7f8c8d 0%, #95a5a6 100%);
}

/* Inline-Validierungen */
.validation-inline {
    margin: 15px 0;
    padding: 15px;
    border-radius: 6px;
    background: #fff3cd;
    border-left: 4px solid var(--warning-color);
    display: none;
}

.validation-inline.error {
    background: #f8d7da;
    border-left-color: var(--error-color);
}

.validation-inline.info {
    background: #d1ecf1;
    border-left-color: #17a2b8;
}

.validation-header-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--error-color);
}

.validation-inline.info .validation-header-inline {
    color: #0c5460;
}

.validation-header-inline .validation-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.validation-inline .error-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.validation-inline .error-list li {
    padding: 5px 0;
    color: #721c24;
}

.validation-inline.info .error-list li {
    color: #0c5460;
}

/* SVG-Symbole für Warnmeldungen */
.symbol-gk-belegt {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%232e7d32" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
    margin: 0 2px;
}

.symbol-gk-eingebracht {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%231b5e20" stroke-width="2"/><line x1="7" y1="7" x2="17" y2="17" stroke="%231b5e20" stroke-width="2"/><line x1="17" y1="7" x2="7" y2="17" stroke="%231b5e20" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
    margin: 0 2px;
}

/* Validierungszeilen in Tabelle */
.af-validation-row,
.fach-validation-row {
    background: #ffe5e5;
}

.af-validation,
.fach-validation {
    padding: 10px 15px !important;
    background: #ffe5e5;
    border-left: 4px solid var(--error-color) !important;
}

/* Blauer Stil für Info-Nachrichten in AF-Validierung */
.af-validation.info {
    background: #d1ecf1 !important;
    border-left-color: #17a2b8 !important;
}

.af-validation .error-list,
.fach-validation .error-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.af-validation .error-list li,
.fach-validation .error-list li {
    padding: 5px 0;
    color: #856404;
}

.af-validation.info .error-list li {
    color: #0c5460;
}

.course-cell {
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.2s ease, transform 0.1s ease;
    user-select: none;
    font-weight: bold;
    width: 80px;
    min-width: 80px;
}

.course-cell:hover {
    background: #f0f0f0;
    transform: scale(1.02);
}

.course-cell.gk-belegt {
    background: var(--gk-belegt-bg);
    color: var(--gk-belegt-color);
    position: relative;
}

.course-cell.gk-belegt::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%232e7d32" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
}

.course-cell.gk-eingebracht {
    background: var(--gk-eingebracht-bg);
    color: var(--gk-eingebracht-color);
    position: relative;
}

.course-cell.gk-eingebracht::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%231b5e20" stroke-width="2"/><line x1="7" y1="7" x2="17" y2="17" stroke="%231b5e20" stroke-width="2"/><line x1="17" y1="7" x2="7" y2="17" stroke="%231b5e20" stroke-width="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
}

.course-cell.lk {
    background: var(--lk-bg);
    color: var(--lk-color);
    cursor: not-allowed;
}

.course-cell[data-locked="true"] {
    cursor: not-allowed;
}

.course-cell[data-locked="true"]:hover {
    transform: none;
}

.sum-cell {
    background: #fff8e1;
    color: #f57c00;
    font-weight: bold;
    font-size: 1.2rem;
}

#course-table tbody tr:hover {
    background: #fafafa;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #2980b9 100%);
    color: var(--white);
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    display: block;
    margin: var(--spacing-lg) auto 0;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ============================================================================
   VALIDIERUNGSERGEBNISSE
   ============================================================================ */

.validation-results {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.validation-results.success {
    background: #d4edda;
    border: 2px solid var(--success-color);
}

.validation-results.error {
    background: #f8d7da;
    border: 2px solid var(--error-color);
}

.validation-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.validation-header.success {
    color: var(--success-color);
}

.validation-header.error {
    color: var(--error-color);
}

.validation-icon {
    font-size: 2rem;
    font-weight: bold;
}

.validation-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.validation-results p {
    color: #155724;
    line-height: 1.6;
}

.error-list {
    list-style: none;
    padding: 0;
}

.error-list li {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    color: #721c24;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

footer {
    background: var(--light-bg);
    padding: var(--spacing-md);
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .section {
        padding: var(--spacing-md);
    }
    
    .section h2 {
        font-size: 1.5rem;
    }
    
    .input-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .legend-items {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    #course-table {
        font-size: 0.9rem;
    }
    
    #course-table th,
    #course-table td {
        padding: 8px;
    }
    
    .course-cell {
        font-size: 1.2rem;
        width: 60px;
        min-width: 60px;
    }
    
    .btn-primary {
        width: 100%;
        padding: 12px 20px;
    }
}

/* Responsive Design für kleinere Bildschirme */
@media (max-width: 768px) {
    .container {
        border-radius: 0;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .section {
        padding: var(--spacing-md);
    }
    
    .section h2 {
        font-size: 1.3rem;
    }
    
    .fs-selection,
    .pf-selection {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    /* Tabellen-Wrapper für Scrolling */
    .table-wrapper {
        margin: 0 calc(-1 * var(--spacing-md));
        padding: 0 var(--spacing-md);
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }
    
    #course-table {
        font-size: 0.85rem;
        width: 100%;
        min-width: 400px;
    }
    
    /* Feste Spaltenbreiten für bessere mobile Ansicht */
    .fach-col {
        width: 50px;
        min-width: 50px;
        position: sticky;
        left: 0;
        background: white;
        z-index: 10;
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    }
    
    #course-table thead th:first-child {
        position: sticky;
        left: 0;
        background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
        z-index: 11;
    }
    
    /* Fachzellen auch sticky machen */
    .fach-cell {
        position: sticky;
        left: 0;
        background: white;
        z-index: 9;
    }
    
    /* AF-Header auch sticky */
    .af-header-row td {
        position: sticky;
        left: 0;
        z-index: 8;
        background: linear-gradient(135deg, #40916c 0%, #2d6a4f 100%);
    }
    
    #course-table th {
        font-size: 0.85rem;
        padding: 10px 6px;
    }
    
    #course-table th:not(:first-child) {
        min-width: 55px;
    }
    
    /* Auf kleinen Bildschirmen: Nur Kürzel zeigen */
    .fach-cell .fach-name {
        display: none;
    }
    
    .fach-cell .fach-kuerzel {
        display: block;
        font-weight: bold;
        font-size: 0.8rem;
    }
    
    .fach-cell {
        padding: 10px 4px;
        min-width: 50px;
        max-width: 50px;
        white-space: nowrap;
        position: sticky;
        left: 0;
        background: white;
        z-index: 9;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .course-cell {
        font-size: 1.3rem;
        min-width: 55px;
        padding: 10px 6px;
    }
    
    .sum-cell {
        min-width: 60px;
        max-width: 60px;
        font-weight: bold;
        font-size: 0.9rem;
        padding: 10px 4px;
    }
    
    .af-header {
        font-size: 0.85rem;
        padding: 8px;
    }
    
    .btn-primary {
        width: 100%;
        padding: 12px 20px;
    }
}

/* Für sehr kleine Bildschirme (Smartphones) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .section {
        padding: var(--spacing-sm);
    }
    
    .table-wrapper {
        margin: 0 calc(-1 * var(--spacing-sm));
        padding: 0 var(--spacing-sm);
    }
    
    #course-table {
        font-size: 0.75rem;
        min-width: 350px;
    }
    
    .fach-col {
        width: 45px;
        min-width: 45px;
    }
    
    #course-table th:not(:first-child) {
        min-width: 50px;
    }
    
    #course-table th {
        font-size: 0.75rem;
        padding: 8px 4px;
    }
    
    .course-cell {
        font-size: 1.1rem;
        min-width: 50px;
        padding: 8px 4px;
    }
    
    .fach-cell {
        padding: 8px 3px;
        min-width: 45px;
        max-width: 45px;
    }
    
    .fach-cell .fach-kuerzel {
        font-size: 0.75rem;
    }
    
    .sum-cell {
        min-width: 55px;
        max-width: 55px;
        font-size: 0.85rem;
        padding: 8px 3px;
    }
    
    .af-header {
        font-size: 0.75rem;
        padding: 6px;
    }
    
    .btn-primary {
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
    }
}

/* Desktop: Voller Name anzeigen */
@media (min-width: 769px) {
    .fach-cell .fach-name {
        display: block;
        font-weight: bold;
    }
    
    .fach-cell .fach-kuerzel {
        display: block;
        font-size: 0.85rem;
        color: #666;
        margin-top: 2px;
    }
}

@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
    }
    
    header {
        background: var(--primary-color);
    }
    
    .btn-primary {
        display: none;
    }
    
    .validation-badge {
        display: none;
    }
}

/* ============================================================================
   VALIDATION BADGE (Floating)
   ============================================================================ */

.validation-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
}

.validation-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.validation-badge.valid {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.validation-badge.invalid {
    background: linear-gradient(135deg, #f44336, #da190b);
    animation: pulse 2s infinite;
}

.badge-icon {
    font-size: 28px;
    color: white;
    line-height: 1;
}

.badge-count {
    font-size: 12px;
    font-weight: bold;
    color: white;
    margin-top: 2px;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 6px 20px rgba(244, 67, 54, 0.5);
    }
}

/* Responsive Badge für mobile Geräte */
@media (max-width: 768px) {
    .validation-badge {
        width: 50px;
        height: 50px;
        top: 15px;
        right: 15px;
    }
    
    .badge-icon {
        font-size: 24px;
    }
    
    .badge-count {
        font-size: 10px;
    }
}

