@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --widget-bg: rgba(30, 41, 59, 0.7); /* Leicht transparent für Milchglas */
    --widget-border: rgba(255, 255, 255, 0.1);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: white;
    margin: 0;
    overflow: hidden;
    height: 100dvh;
    width: 100dvw;
}

.board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    z-index: 1;


    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* --- Moderne Toolbar im Milchglas-Look --- */
.toolbar {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px); /* Der Milchglas-Effekt */
    -webkit-backdrop-filter: blur(12px);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--widget-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1000;
}

.toolbar.hidden {
    display: none !important;
}

.toolbar-right-group .btn-primary[title="Export"],
.toolbar-right-group .btn-primary[title="Import"] {
    padding: 6px 10px;
    font-size: 0.9rem;
    min-width: unset;
    text-shadow: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.toolbar-right-group .btn-primary[title="Export"]:hover,
.toolbar-right-group .btn-primary[title="Import"]:hover {
    background: rgba(255, 255, 255, 0.1);
}

.brand {
    font-weight: 600;
    font-size: 1.2rem;
    color: #e2e8f0;
    margin-right: 20px;
    letter-spacing: 0.5px;
}

/* Der kleine, schwebende Button, um den Vollbildmodus zu beenden */
.floating-exit-btn {
    position: fixed;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.5); /* Semi-transparent */
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 2000; /* Immer im Vordergrund */
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}

.floating-exit-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    transform: scale(1.05);
}

/* --- Schicke Buttons mit Hover-Animation --- */
button {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border: 1px solid var(--widget-border);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px); /* Knopf hebt sich leicht an */
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-primary { background: var(--accent); border: none; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-export { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.btn-export:hover { background: rgba(16, 185, 129, 0.3); }
.btn-import { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.4); color: #a78bfa; }
.btn-import:hover { background: rgba(139, 92, 246, 0.3); }

.btn-small {
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}


.widget {
    position: absolute;
    background: var(--widget-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border: 1px solid var(--widget-border);
    transition: box-shadow 0.2s ease;

    /* ÄNDERUNG: Standard-Mauszeiger für das normale Fenster */
    cursor: default;

    resize: both;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 120px;
    min-height: 80px;
}

.widget:hover {
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

/* ... Header bleibt wie er ist. ... */

.widget-content {
    padding: 5px;
    flex-grow: 1; /* NEU: Inhalt füllt immer den neu gewonnenen Platz aus */
    display: flex;
    flex-direction: column;
    cursor: default;
}

/* --- Widget Header --- */
.widget-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 15px;
    border-radius: 15px 15px 0 0;
    cursor: grab; /* Zeigt eine "Greif-Hand" an */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.widget-header:active { cursor: grabbing; } /* Hand greift zu beim Ziehen */

.widget-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.widget-content textarea,
.widget-content input {
    user-select: text;
    cursor: text;
}

/* --- APPLE & SAFARI OPTIMIERUNG FÜR DAS RESIZE-FELD --- */
.widget::-webkit-resizer {
    background-color: var(--accent);
    /* Macht ein schickes, geriffeltes Muster unten rechts */
    background-image: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.5) 3px,
        rgba(255, 255, 255, 0.5) 6px
    );
    border-top-left-radius: 8px; /* Leicht abgerundet nach innen */
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
}

/* Verhindert, dass Text auf dem iPad beim versehentlichen Doppeltippen markiert wird */
.widget-header, .btn-primary, .schueler-tag {
    -webkit-user-select: none;
    user-select: none;
}

/* Versteckt das Handle im Transparent-Modus */
.widget.ghost-mode .custom-resize-handle {
    opacity: 0;
    pointer-events: none; /* Verhindert, dass man es aus Versehen greift */
    transition: opacity 0.3s ease;
}

/* Zeigt das Handle nur, wenn man die Kachel berührt/darüberfährt */
.widget.ghost-mode:hover .custom-resize-handle,
.widget.ghost-mode:active .custom-resize-handle {
    opacity: 1;
    pointer-events: auto;
}

/* Optional: Damit man im Transparent-Modus auch den Header
   wieder sieht, wenn man ihn anfassen will (hast du ja schon ähnlich drin) */
.widget.ghost-mode:hover .widget-header {
    opacity: 1;
}

.draggable-name {
    -webkit-user-select: none;   /* Verhindert Textmarkierung */
    -webkit-touch-callout: none; /* Verhindert das Kontextmenü (Suche) bei langem Drücken */
    user-select: none;
    touch-action: none;          /* Hilft dem iPad zu verstehen, dass wir hier selbst ziehen */
}

.close-btn {
    color: #ef4444;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.close-btn:hover { opacity: 1; }

/* --- Settings Modal & Klassenverwaltung --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center; z-index: 3000;
}

.settings-modal {
    background: rgba(15, 23, 42, 0.95); width: 550px; max-width: 90vw; max-height: 85vh;
    border-radius: 16px; border: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column; box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
}

.modal-header h2 { margin: 0; font-size: 1.3rem; color: #e2e8f0; }

.modal-body { padding: 20px; overflow-y: auto; }

.input-group { display: flex; gap: 10px; margin-bottom: 20px; }
.input-group input {
    flex-grow: 1; padding: 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.2); color: white; outline: none; font-size: 1rem;
}
.input-group input:focus { border-color: var(--accent); }

.klasse-item {
    background: rgba(255,255,255,0.05); padding: 15px; border-radius: 10px;
    margin-bottom: 15px; border: 1px solid rgba(255,255,255,0.05);
}

.klasse-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.schueler-tags { display: flex; flex-wrap: wrap; gap: 8px; }

/* Normaler Schüler (Anwesend) */
.schueler-tag {
    background: var(--accent); color: white; padding: 4px 10px; border-radius: 6px;
    font-size: 0.9rem; display: flex; align-items: center; gap: 6px; cursor: pointer;
    transition: all 0.2s; user-select: none; border: 1px solid transparent;
}
.schueler-tag:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Kranker Schüler (Abwesend) */
.schueler-tag.is-absent {
    background: rgba(239, 68, 68, 0.15);
    color: rgba(255, 255, 255, 0.5);
    text-decoration: line-through;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.schueler-tag.is-absent:hover { background: rgba(239, 68, 68, 0.25); }

/* Das X zum Löschen eines Schülers */
.remove-s {
    background: rgba(0,0,0,0.2); border-radius: 50%; width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
    transition: all 0.2s;
}
.remove-s:hover { background: #ef4444; color: white; }

/* Button um neuen Schüler hinzuzufügen */
.add-s-btn {
    background: transparent; border: 1px dashed rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.7); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
    transition: all 0.2s;
}
.add-s-btn:hover { background: rgba(255,255,255,0.1); color: white; border-color: white; }

/* Badge oben links in der Toolbar */
.active-profile-badge {
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 10px;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Badge für die aktive Klasse im Modal */
.active-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Button zum Profil wechseln im Modal */
.switch-btn {
    background: var(--accent) !important;
    color: white !important;
    border: none !important;
}
.switch-btn:hover {
    background: var(--accent-hover) !important;
}

/* Das neue Eingabefeld für Schüler */
.inline-s-input {
    background: rgba(0,0,0,0.3);
    border: 1px dashed rgba(255,255,255,0.3);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    width: 130px;
    transition: all 0.2s;
}
.inline-s-input:focus {
    border-color: var(--accent);
    background: rgba(0,0,0,0.5);
    width: 160px;
}
/* --- Dropdown Menü für Widgets --- */
.dropdown {
    position: relative;
    display: inline-block;
    margin-right: 15px;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--widget-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);

    /* NEU: Breite angepasst für zwei Spalten */
    min-width: 380px;

    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
    border: 1px solid var(--widget-border);
    border-radius: 8px;
    z-index: 1000;
    padding: 12px;
    margin-top: 10px;

    /* NEU: Grid-Layout für zwei Spalten */
    display: grid;
    grid-template-columns: 1fr 1fr; /* Zwei gleich große Spalten nebeneinander */
    gap: 6px; /* Abstand zwischen den Buttons */
}

.dropdown-content button {
    background: transparent;
    color: white;
    padding: 10px 15px;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1rem;
    transition: background 0.2s;
}

.dropdown-content button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Eigene Ecke zum Vergrößern (iPad Fix) --- */
.widget {
    resize: none !important; /* Schaltet den fehlerhaften Standard ab */
}

.custom-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.4) 50%);
    border-bottom-right-radius: 12px;
    z-index: 10;
}

/* --- Copyright Style --- */
.copyright {
    position: fixed;
    bottom: 5px;
    right: 5px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4); /* Sehr dezent */
    pointer-events: none; /* Klicks gehen "hindurch" */
    z-index: 1000;
    font-family: inherit;
}