/* =========================================
   1. CSS VARIABLEN & FARBEN
   ========================================= */
:root {
    --bg-color: #f4f7f6;
    --text-main: #2d3436;
    --text-muted: #636e72;
    
    --blue: #74b9ff;
    --mint: #55efc4;
    --mint-dark: #00b894;
    --rose: #fab1a0;
    --rose-dark: #e17055;
    --sand: #ffeaa7;
    --purple: #a29bfe;
    
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.05);
    
    --radius-box: 16px;
    --radius-btn: 12px;
    --shadow-btn: 0 4px 15px rgba(0,0,0,0.05);
}

body.dark-mode {
    --bg-color: #1e272e;
    --text-main: #f5f6fa;
    --text-muted: #a4b0be;
    --glass-bg: rgba(47, 54, 64, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* =========================================
   2. GRUND-LAYOUT & TYPOGRAFIE
   ========================================= */
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { margin: 0; padding: 15px; background: var(--bg-color); color: var(--text-main); font-size: 16px; transition: background 0.3s ease, color 0.3s ease; }

.glass-box { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-box); box-shadow: var(--shadow-btn); }

.lock-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; text-align: center; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* =========================================
   3. EINGABEFELDER & BUTTONS
   ========================================= */
input, select, textarea { width: 100%; padding: 10px; margin-bottom: 15px; border-radius: var(--radius-btn); border: 1px solid rgba(0,0,0,0.1); background: rgba(255,255,255,0.9); font-size: 1rem; color: var(--text-main); }
body.dark-mode input, body.dark-mode select, body.dark-mode textarea { background: rgba(0,0,0,0.2); color: white; border-color: rgba(255,255,255,0.1); }

.btn { padding: 10px 15px; border: none; border-radius: var(--radius-btn); cursor: pointer; font-weight: bold; background: white; color: var(--text-main); box-shadow: var(--shadow-btn); transition: transform 0.1s, filter 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn:active { transform: scale(0.96); }
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--blue); color: #000; }
.btn-success { background: var(--mint-dark); color: white; }
.btn-danger { background: var(--rose-dark); color: white; }

.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.2rem; }
.btn-icon-small { background: transparent; border: none; cursor: pointer; padding: 5px; font-size: 1rem; border-radius: 50%; transition: background 0.2s; }
.btn-icon-small:hover { background: rgba(0,0,0,0.05); }

/* =========================================
   4. HEADER & TABS
   ========================================= */
header { display: flex; justify-content: space-between; align-items: center; padding: 15px; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
header h1 { margin: 0; display: flex; align-items: center; gap: 15px; font-size: 1.5rem; }
.header-buttons { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.timer-display { background: white; padding: 10px 15px; border-radius: var(--radius-btn); font-weight: 800; font-family: monospace; font-size: 1.1rem; box-shadow: var(--shadow-btn); cursor: pointer; color: black; }
.timer-display.alert { background: var(--rose-dark); color: white; animation: pulse 1s infinite; }

.tabs-container { display: flex; justify-content: space-between; align-items: center; padding: 10px; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.tabs-left, .view-toggle { display: flex; gap: 8px; flex-wrap: wrap; }

.tab-btn { padding: 8px 18px; border-radius: 20px; cursor: pointer; font-weight: 700; font-size: 0.9rem; background: rgba(0,0,0,0.05); color: var(--text-muted); transition: 0.2s; display: flex; align-items: center; gap: 6px; border: none; }
.tab-btn.active { background: #333; color: #fff; }
body.dark-mode .tab-btn.active { background: #fff; color: #000; }
.tab-btn-add { border: 2px dashed rgba(0,0,0,0.2); background: transparent; }

/* =========================================
   5. POPUP-FENSTER (MODALS)
   ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); z-index: 1000; display: none; justify-content: center; align-items: center; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal { background: var(--bg-color); padding: 25px; border-radius: var(--radius-box); width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal h2 { margin-top: 0; border-bottom: 2px solid var(--blue); padding-bottom: 10px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }

/* =========================================
   6. TABELLE (UNTERRICHTSMODUS)
   ========================================= */
.table-container { overflow-x: auto; padding-bottom: 20px; }
table { width: 100%; border-collapse: collapse; text-align: left; background: white; border-radius: var(--radius-box); overflow: hidden; }
body.dark-mode table { background: var(--glass-bg); }
th, td { padding: 15px 10px; border-bottom: 1px solid rgba(0,0,0,0.05); }
th { font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }

.sticky-col { position: sticky; left: 0; background: inherit; z-index: 2; border-right: 2px solid rgba(0,0,0,0.05); width: 1%; white-space: nowrap; }

.name-wrapper { display: flex; justify-content: flex-start; align-items: center; gap: 15px; }
.name-text-area { font-weight: bold; font-size: 1.05rem; cursor: pointer; }
.student-inline-note { font-size: 0.75rem; color: var(--text-muted); font-weight: normal; margin-top: 3px; }

.student-row:hover td { background: rgba(0,0,0,0.02); }
.student-row.is-absent td { opacity: 0.5; background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.02) 10px, rgba(0,0,0,0.02) 20px); }

.part-layout { display: flex; gap: 10px; align-items: center; margin-bottom: 5px; flex-wrap: nowrap; white-space: nowrap; }
.recorded-items { display: flex; gap: 3px; flex-wrap: nowrap; }
.action-group { display: flex; flex-direction: row; gap: 6px; align-items: center; flex-wrap: nowrap; }

.circle { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.85rem; cursor: pointer; color: white; }
.circle.plus { background: var(--mint-dark); }
.circle.minus { background: var(--rose-dark); }
.circle.tu { background: var(--blue); color: black; width: 32px; }

.action-btn { width: 28px; height: 28px; border-radius: 50%; border: none; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: white; }
.action-btn.aplus { background: var(--mint); }
.action-btn.aminus { background: var(--rose); }

.grade-badge { padding: 4px 10px; border-radius: 12px; font-weight: 800; font-size: 0.8rem; color: white; background: #95a5a6; }
.grade-badge.g1 { background: #27ae60; } .grade-badge.g2 { background: #2ecc71; } .grade-badge.g3 { background: #f1c40f; color: black; } .grade-badge.g4 { background: #e67e22; } .grade-badge.g5, .grade-badge.g6 { background: #e74c3c; }

.counter-box { display: flex; align-items: center; gap: 8px; }
.counter-val { font-weight: bold; font-size: 1.1rem; cursor: pointer; padding: 2px 8px; background: rgba(0,0,0,0.05); border-radius: 8px; }
.counter-btn { border: none; background: var(--rose); color: white; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-weight: bold; }
.check-box { width: 30px; height: 30px; border-radius: 8px; background: rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.2rem; user-select: none; }
.check-box.c1 { background: var(--mint); } .check-box.c2 { background: var(--rose); }

/* =========================================
   7. SITZPLAN
   ========================================= */
.seating-container { display: flex; flex-direction: column; gap: 10px; }
.seating-wrapper { overflow-x: auto; padding: 10px 0 20px 0; }
.seating-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; min-width: 800px; }
.desk { background: rgba(0,0,0,0.02); border: 2px dashed rgba(0,0,0,0.1); border-radius: 12px; height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: 0.2s; }
.desk:hover { background: rgba(0,0,0,0.05); }
.desk.occupied { border-style: solid; background: white; box-shadow: var(--shadow-btn); }
body.dark-mode .desk.occupied { background: var(--glass-bg); }
.desk.target { border-color: var(--blue); background: var(--blue); opacity: 0.8; }
.desk-name { font-weight: bold; text-align: center; font-size: 0.9rem; pointer-events: none; }
.desk-remove { position: absolute; top: -5px; right: -5px; background: var(--rose-dark); color: white; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 0.7rem; cursor: pointer; display: none; }
.desk:hover .desk-remove { display: block; }
.desk-actions { display: flex; gap: 5px; margin-top: 5px; }

.unseated-pool { display: flex; flex-wrap: wrap; gap: 10px; padding: 15px; background: rgba(0,0,0,0.02); border-radius: var(--radius-box); min-height: 60px; }
.student-pill { padding: 8px 15px; background: white; border-radius: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); cursor: pointer; font-weight: bold; font-size: 0.9rem; border: 2px solid transparent; }
body.dark-mode .student-pill { background: rgba(255,255,255,0.1); }
.student-pill.selected { border-color: var(--blue); background: var(--blue); color: black; }
.student-pill.is-absent { opacity: 0.5; text-decoration: line-through; }

/* =========================================
   8. NOTIZEN (Grid) & KANBAN
   ========================================= */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.note-card { background: white; padding: 15px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.02); border-left: 5px solid gray; display: flex; flex-direction: column; }
body.dark-mode .note-card { background: var(--glass-bg); }
.note-card.done { opacity: 0.6; }
.note-badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: bold; margin-bottom: 10px; }
.note-text-content { font-size: 0.95rem; line-height: 1.4; }
.note-footer { margin-top: 15px; padding-top: 10px; border-top: 1px dashed rgba(0,0,0,0.1); font-size: 0.8rem; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

.kanban-board { display: flex; gap: 15px; overflow-x: auto; height: 100%; padding-bottom: 10px; }
.kanban-column { background: rgba(0,0,0,0.02); border-radius: 12px; border: 1px solid rgba(0,0,0,0.05); width: 300px; min-width: 300px; display: flex; flex-direction: column; }
.kanban-header { font-weight: 800; padding: 15px; border-bottom: 2px solid rgba(0,0,0,0.05); }
.kanban-cards { padding: 10px; flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.k-card { background: white; padding: 12px; border-radius: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-left: 4px solid gray; cursor: grab; font-size: 0.9rem; display: flex; flex-direction: column; }
body.dark-mode .k-card { background: rgba(255,255,255,0.05); }
.k-card:active { cursor: grabbing; transform: scale(0.98); }
.k-card.done { opacity: 0.6; }
.k-person { font-weight: bold; color: var(--text-muted); font-size: 0.8rem; }
.k-text { margin: 10px 0; line-height: 1.4; }
.k-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed rgba(0,0,0,0.1); padding-top: 8px; font-size: 0.8rem; }
.k-status-select { padding: 2px 5px; font-size: 0.8rem; margin: 0; width: auto; border: none; background: rgba(0,0,0,0.05); border-radius: 8px; color: var(--text-main); }

/* =========================================
   9. SCHULLEITUNGS-MODULE
   ========================================= */

.sop-card { background: white; padding: 15px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border-left: 5px solid var(--purple); display: flex; flex-direction: column; position: relative; }
body.dark-mode .sop-card { background: var(--glass-bg); }
.sop-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 10px; margin-bottom: 10px; }
.sop-title { font-weight: 800; font-size: 1.05rem; }
.sop-person { font-size: 0.85rem; color: gray; font-weight: bold; margin-top: 3px; }
.sop-step { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,0.05); cursor: pointer; font-size: 0.9rem; }
.sop-step:hover { background: rgba(0,0,0,0.02); }
.sop-step.done { opacity: 0.5; text-decoration: line-through; }
.sop-progress-bar { height: 6px; background: rgba(0,0,0,0.05); border-radius: 3px; margin-top: 15px; overflow: hidden; }
.sop-progress-fill { height: 100%; background: var(--mint-dark); width: 0%; transition: width 0.3s ease; }

.staff-card { background: white; padding: 15px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); display: flex; flex-direction: column; border-left: 5px solid var(--blue); }
body.dark-mode .staff-card { background: var(--glass-bg); }
.staff-card.status-red { border-left-color: var(--rose-dark); }
.staff-card.status-yellow { border-left-color: #f1c40f; }
.staff-card.status-green { border-left-color: var(--mint-dark); }
.staff-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 5px; }
.staff-role-badge { display: inline-block; background: rgba(0,0,0,0.05); padding: 3px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; margin-bottom: 10px; }
.staff-info-row { font-size: 0.85rem; display: flex; justify-content: space-between; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dashed rgba(0,0,0,0.05); }

.link-category-block { background: rgba(0,0,0,0.02); border-radius: 12px; padding: 15px; border: 1px solid rgba(0,0,0,0.05); display: flex; flex-direction: column; }
.link-category-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 15px; display: inline-block; padding: 4px 12px; border-radius: 12px; color: #000; align-self: flex-start; }
.link-grid { display: flex; flex-direction: column; gap: 10px; }
.link-btn { background: white; border: 1px solid rgba(0,0,0,0.05); padding: 12px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: var(--text-main); font-weight: 600; font-size: 0.9rem; box-shadow: 0 2px 5px rgba(0,0,0,0.02); transition: all 0.2s; cursor: pointer; }
body.dark-mode .link-btn { background: var(--glass-bg); }
.link-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.link-icon { font-size: 1.2rem; }

.contact-card { background: white; padding: 15px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); display: flex; flex-direction: column; position: relative; border-left: 5px solid gray; }
body.dark-mode .contact-card { background: var(--glass-bg); }
.contact-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 2px; }
.contact-role { font-size: 0.85rem; color: gray; margin-bottom: 10px; font-weight: bold; }
.contact-detail { font-size: 0.9rem; display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.contact-detail a { color: var(--blue); text-decoration: none; font-weight: 600; }
.contact-detail a:hover { text-decoration: underline; }

.conf-card { background: white; padding: 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0,0,0,0.05); display: flex; justify-content: space-between; align-items: center; cursor: grab; margin-bottom: 8px; }
body.dark-mode .conf-card { background: var(--glass-bg); }
.conf-card:active { cursor: grabbing; transform: scale(0.98); }
.conf-time-badge { background: var(--purple); color: #000; font-weight: 800; font-size: 0.75rem; padding: 3px 6px; border-radius: 8px; }

/* =========================================
   10. TISCHKALENDER / WOCHENPLANER (EINKLAPPBAR)
   ========================================= */
#calendar-grid { -webkit-overflow-scrolling: touch; } 

.cal-day-col { 
    flex: 1; 
    min-width: 210px;
    background: rgba(255,255,255,0.95); 
    border: 1px solid rgba(0,0,0,0.1); border-radius: 12px; 
    display: flex; flex-direction: column; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
}
body.dark-mode .cal-day-col { background: var(--glass-bg); }

/* WIEDER BLAU! Nur Feiertage bekommen im JS ein dunkles Grau */
.cal-day-header { 
    background: var(--blue); 
    color: black; 
    font-weight: 900; text-align: center; padding: 12px; 
    font-size: 1.1rem; border-top-left-radius: 12px; border-top-right-radius: 12px; 
}
body.dark-mode .cal-day-header { background: #34495e; color: white; }

.cal-details { border-bottom: 1px solid rgba(0,0,0,0.05); }
.cal-section-title { 
    background: rgba(0,0,0,0.03); font-weight: bold; font-size: 0.85rem; 
    padding: 12px 10px; margin: 0; text-transform: uppercase; 
    letter-spacing: 1px; color: var(--text-main); 
    cursor: pointer; display: flex; justify-content: space-between; align-items: center; 
    list-style: none; 
}
.cal-section-title::-webkit-details-marker { display: none; }
.cal-section-title::after { content: '▼'; font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
details[open] .cal-section-title::after { transform: rotate(180deg); } 

.cal-details-content { padding: 5px 0; background: white; }
body.dark-mode .cal-details-content { background: transparent; }

.cal-input-row { display: flex; border-bottom: 1px dashed rgba(0,0,0,0.1); }
.cal-input-label { width: 45px; text-align: right; padding: 8px 5px; font-size: 0.75rem; color: var(--text-muted); border-right: 1px solid rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: flex-end; font-weight:bold; }
.cal-input-field { border: none !important; background: transparent !important; padding: 8px !important; flex-grow: 1; font-size: 0.9rem !important; margin: 0 !important; border-radius: 0 !important; outline: none; box-shadow:none !important; }
.cal-input-field:focus { background: rgba(0,0,0,0.02) !important; }

/* Die Randnotiz */
.cal-textarea { width: 100%; border: none; background: transparent; padding: 10px; font-size: 0.95rem; resize: none; outline: none; }
.cal-textarea:focus { background: rgba(0,0,0,0.02); }

/* =========================================
   11. ANIMATIONEN & DRUCK-LAYOUT
   ========================================= */
.animate-in { animation: fadeIn 0.3s ease forwards; opacity: 0; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media print {
    body * { visibility: hidden; }
    #view-conf, #view-conf * { visibility: visible; }
    #view-conf { position: absolute; left: 0; top: 0; width: 100%; display: block !important; }
    .kanban-board { display: block; }
    #conf-pool, .kanban-header:first-child, .header-buttons, .view-toggle, .tabs-left, input, button { display: none !important; }
    .kanban-column { border: none !important; background: transparent !important; }
    .conf-card { border: none; border-bottom: 1px solid #ccc; box-shadow: none; padding: 15px 0; font-size: 12pt; page-break-inside: avoid;}
}