/* ============================================================
   Klassenkonferenz-Planer - Stylesheet
   ============================================================ */

:root {
    --primary: #2c3e50;
    --primary-light: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #2980b9;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dcdde1;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --radius: 8px;
    --parallel-bg: rgba(52, 152, 219, 0.2);
    --excused-bg: rgba(231, 76, 60, 0.2);
    --quorum-warning-bg: rgba(243, 156, 18, 0.2);
    --pause-bg: rgba(149, 165, 166, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* ============================================================
   HEADER / NAVIGATION
   ============================================================ */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.app-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.app-header .date-display {
    font-size: 0.85rem;
    opacity: 0.85;
}

.nav-bar {
    display: flex;
    gap: 2px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.nav-bar button {
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.nav-bar button:hover { background: rgba(255,255,255,0.25); }
.nav-bar button.active { background: var(--card-bg); color: var(--primary); font-weight: 600; }

/* ============================================================
   CONTAINER / CARDS
   ============================================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg);
}

.card h3 {
    font-size: 0.95rem;
    color: var(--primary);
    margin: 12px 0 6px;
}

.card .help-text {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #f0f4ff;
    border-left: 3px solid var(--primary-light);
    border-radius: 0 4px 4px 0;
}

/* ============================================================
   FORMULARE
   ============================================================ */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
}

.inline-form .form-group { margin-bottom: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary-light); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-xs { padding: 2px 6px; font-size: 0.72rem; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

/* ============================================================
   TABELLEN
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.82rem;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

tr:hover { background: rgba(52, 152, 219, 0.04); }

/* ============================================================
   KONFERENZ-ANSICHT SPEZIAL
   ============================================================ */
.conference-table th {
    background: var(--primary);
    min-width: 160px;
}

.conference-table th:first-child { min-width: 80px; }

.conference-cell {
    padding: 6px 8px;
    min-height: 60px;
    position: relative;
}

.conference-cell.pause-cell {
    background: var(--pause-bg);
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

.conference-cell.quorum-warning {
    background: var(--quorum-warning-bg);
}

.class-header {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.teacher-tag {
    display: inline-block;
    padding: 2px 6px;
    margin: 1px 2px;
    border-radius: 3px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.teacher-tag.present { background: rgba(39, 174, 96, 0.1); }
.teacher-tag.parallel { background: var(--parallel-bg); }
.teacher-tag.excused { background: var(--excused-bg); text-decoration: line-through; }
.teacher-tag.leader { font-weight: 700; border: 1px solid var(--primary-light); }

.quorum-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 6px;
}

.quorum-ok { background: rgba(39, 174, 96, 0.15); color: var(--success); }
.quorum-fail { background: rgba(231, 76, 60, 0.15); color: var(--danger); }

/* ============================================================
   TAGS / BADGES
   ============================================================ */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-excused { background: var(--excused-bg); color: var(--danger); }
.tag-active { background: rgba(39, 174, 96, 0.15); color: var(--success); }

/* ============================================================
   LOGIN-DIALOG
   ============================================================ */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 62, 80, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-box {
    background: white;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 340px;
    max-width: 90%;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 16px;
    color: var(--primary);
    border: none;
}

.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ============================================================
   ADMIN-BEREICH SPEZIFISCH
   ============================================================ */
.admin-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
}

.admin-steps .step-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
}

.admin-steps .step-btn.active {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

.admin-steps .step-btn:hover:not(.active) { background: var(--bg); }

.step-number {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    text-align: center;
    line-height: 20px;
    font-size: 0.7rem;
    margin-right: 4px;
}

.step-btn.active .step-number { background: white; color: var(--primary-light); }

/* Liste mit Tags */
.item-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}

.item-list .item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg);
    border-radius: 14px;
    font-size: 0.82rem;
}

.item-list .item .delete-btn {
    cursor: pointer;
    color: var(--danger);
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1;
}

.item-list .item .delete-btn:hover { color: #c0392b; }

.item-list .item.item-inactive {
    opacity: 0.45;
    text-decoration: line-through;
    background: #f0f0f0;
    border: 1px dashed var(--border);
}

.item-list .item.item-inactive:hover { opacity: 0.7; }

/* Track-Konfiguration */
.track-config {
    display: grid;
    grid-template-columns: 60px 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.track-config:last-child { border-bottom: none; }

/* Klassen-Zuordnung */
.class-assignment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.class-assign-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.class-assign-card .class-name {
    font-weight: 600;
    min-width: 50px;
}

/* ============================================================
   LEHRER-PLAN (öffentlich)
   ============================================================ */
.teacher-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 4px;
    margin: 12px 0;
}

.teacher-select-grid .teacher-btn {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    background: white;
    transition: all 0.2s;
}

.teacher-select-grid .teacher-btn:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

.teacher-select-grid .teacher-btn.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Expand Button */
.expand-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.expand-btn:hover { background: var(--primary-light); color: white; }

.participant-detail {
    display: none;
    padding: 6px 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.participant-detail.open { display: block; }

/* ============================================================
   ALERTS / MESSAGES
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.alert-success { background: rgba(39, 174, 96, 0.1); color: var(--success); border: 1px solid rgba(39, 174, 96, 0.3); }
.alert-error { background: rgba(231, 76, 60, 0.1); color: var(--danger); border: 1px solid rgba(231, 76, 60, 0.3); }
.alert-info { background: rgba(52, 152, 219, 0.1); color: var(--info); border: 1px solid rgba(52, 152, 219, 0.3); }

/* ============================================================
   LINK-BEREICH
   ============================================================ */
a.class-link {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

a.class-link:hover { text-decoration: underline; }

a.time-link {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

a.time-link:hover { text-decoration: underline; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .container { padding: 8px; }
    .card { padding: 12px; }

    .nav-bar button {
        padding: 5px 10px;
        font-size: 0.78rem;
    }

    .conference-table th { min-width: 120px; }
    .conference-table th:first-child { min-width: 60px; }

    .inline-form { flex-direction: column; }
    .inline-form .form-group { width: 100%; }

    .track-config { grid-template-columns: 1fr; gap: 4px; }

    th, td { padding: 6px; font-size: 0.78rem; }

    .teacher-tag { font-size: 0.72rem; padding: 1px 4px; }

    .admin-steps { gap: 2px; }
    .admin-steps .step-btn { padding: 4px 8px; font-size: 0.75rem; }

    .class-assignment-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .app-header h1 { font-size: 0.95rem; }
    .nav-bar button { font-size: 0.72rem; padding: 4px 8px; }
    table { font-size: 0.75rem; }
    .teacher-tag { font-size: 0.68rem; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .app-header { position: static; }
    .nav-bar, .btn, .admin-steps { display: none; }
    .card { box-shadow: none; break-inside: avoid; }
    table { font-size: 0.7rem; }
}

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Section toggle visibility */
.section { display: none; }
.section.active { display: block; }

/* Action buttons in conference view */
.slot-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.move-select {
    display: inline-block;
    padding: 0 1px;
    font-size: 0.68rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: white;
    cursor: pointer;
    max-width: 28px;
    margin-left: 1px;
    vertical-align: middle;
}

.move-select:hover { border-color: var(--primary-light); }

/* Swap-Modus */
.swap-handle { cursor: pointer; transition: background 0.15s; border-radius: 4px; padding: 1px 4px; }
.swap-handle:hover { background: rgba(255,193,7,0.15); }
.swap-selected { outline: 3px solid #ffc107 !important; background: #fffde7 !important; }
.swap-empty:hover { background: rgba(255,193,7,0.15); }

/* Verschieben-Dropdown */
.move-conf-select {
    display: inline-block; padding: 0 2px; font-size: 0.72rem;
    border: 1px solid var(--border); border-radius: 3px;
    background: #e8f5e9; cursor: pointer; max-width: 34px;
    margin-left: 4px; vertical-align: middle;
}
.move-conf-select:hover { border-color: var(--success); background: #c8e6c9; }
