/* ============================================================
   🧹 Putzplan Frahmredder – Stylesheet
   Minimalistisch, kontrastreich, mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --------------- Tokens --------------- */
:root {
    --font-main: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg: #0F1117;
    --bg-card: #1A1D27;
    --bg-card-hover: #222632;
    --bg-input: #252A37;
    --border: #2E3345;
    --border-focus: #6366F1;

    --text: #E8E9ED;
    --text-muted: #8B8FA3;
    --text-dim: #5C6078;

    --accent: #6366F1;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #34D399;
    --success-glow: rgba(52, 211, 153, 0.15);
    --warning: #FBBF24;
    --danger: #F87171;
    --danger-glow: rgba(248, 113, 113, 0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.4);

    --transition: 180ms ease;
}

/* --------------- Reset --------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------- Layout --------------- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 60px;
    background: rgba(15, 17, 23, .85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.topbar-brand span { font-size: 1.35rem; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.topbar-nav a, .topbar-nav button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .75rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-main);
    text-decoration: none;
}

.topbar-nav a:hover, .topbar-nav button:hover {
    color: var(--text);
    background: var(--bg-card);
    border-color: var(--border);
    text-decoration: none;
}

.topbar-nav .active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: rgba(99, 102, 241, .25);
}

.lang-switcher {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    padding: 2px;
}

.lang-switcher a {
    padding: .3rem .5rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    border-radius: 4px;
    border: none;
    transition: var(--transition);
}

.lang-switcher a:hover {
    color: var(--text-muted);
    background: transparent;
}

.lang-switcher a.active {
    color: var(--text);
    background: var(--accent);
}

.main-content {
    flex: 1;
    padding: 1.5rem 1.25rem 3rem;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

/* --------------- Stats Bar --------------- */
.stats-bar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, .3);
    box-shadow: 0 0 20px var(--accent-glow);
}

.stat-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
    margin-bottom: .25rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -.03em;
}

.stat-value.overdue { color: var(--danger); }
.stat-value.due { color: var(--warning); }
.stat-value.ok { color: var(--success); }

/* --------------- Room Sections --------------- */
.room-section {
    margin-bottom: 1.5rem;
}

.room-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem 1rem;
    margin-bottom: .5rem;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.room-header::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: .12;
    border-radius: inherit;
}

.room-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.room-name {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.room-count {
    margin-left: auto;
    font-size: .72rem;
    font-weight: 600;
    font-family: var(--font-mono);
    padding: .2rem .5rem;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
}

/* --------------- Task Cards --------------- */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}

.task-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,.08);
}

.task-card.overdue {
    border-left: 3px solid var(--danger);
    background: linear-gradient(90deg, var(--danger-glow) 0%, var(--bg-card) 30%);
}

.task-card.due-today {
    border-left: 3px solid var(--warning);
}

.task-card.due-soon {
    border-left: 3px solid var(--accent);
}

.task-card.on-demand {
    border-left: 3px solid var(--text-dim);
    opacity: .75;
}

/* Checkbox */
.task-check {
    position: relative;
    width: 22px;
    height: 22px;
}

.task-check input[type="checkbox"] {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: var(--transition);
}

.task-check input[type="checkbox"]:hover {
    border-color: var(--success);
    background: var(--success-glow);
}

.task-check input[type="checkbox"]:checked {
    background: var(--success);
    border-color: var(--success);
}

.task-check input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #0F1117;
    font-size: .75rem;
    font-weight: 700;
}

/* Task Info */
.task-info {
    min-width: 0;
}

.task-name {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-name a {
    color: inherit;
    transition: var(--transition);
}

.task-name a:hover {
    color: var(--accent);
    text-decoration: none;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-top: .15rem;
    font-size: .72rem;
    color: var(--text-dim);
}

.task-meta .has-note {
    color: var(--accent);
    cursor: pointer;
}

/* Task Actions */
.task-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    font-size: .68rem;
    font-weight: 600;
    font-family: var(--font-mono);
    border-radius: 20px;
    white-space: nowrap;
}

.badge-overdue { background: var(--danger-glow); color: var(--danger); }
.badge-today { background: rgba(251, 191, 36, .12); color: var(--warning); }
.badge-soon { background: var(--accent-glow); color: var(--accent); }
.badge-ok { background: var(--success-glow); color: var(--success); }
.badge-demand { background: rgba(255,255,255,.05); color: var(--text-dim); }

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-dot.hoch { background: var(--danger); }
.priority-dot.mittel { background: var(--warning); }
.priority-dot.niedrig { background: var(--success); }

.date-edit {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: .72rem;
    padding: .2rem .35rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}

.date-edit:hover {
    border-color: var(--border);
    background: var(--bg-input);
}

.date-edit:focus {
    outline: none;
    border-color: var(--accent);
}

.task-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font-size: .82rem;
    transition: var(--transition);
}

.task-edit-link:hover {
    background: var(--bg-input);
    color: var(--text);
    text-decoration: none;
}

/* --------------- Forms --------------- */
.form-page {
    max-width: 600px;
    margin: 0 auto;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
}

.form-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    letter-spacing: -.02em;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: .35rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: .6rem .85rem;
    font-size: .88rem;
    font-family: var(--font-main);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238B8FA3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.form-hint {
    font-size: .72rem;
    color: var(--text-dim);
    margin-top: .25rem;
}

/* Note language tabs */
.note-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    padding: 2px;
    margin-bottom: .5rem;
    width: fit-content;
}

.note-tab {
    padding: .35rem .75rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-main);
}

.note-tab:hover { color: var(--text-muted); }
.note-tab.active { color: var(--text); background: var(--accent); }

.note-panel { display: none; }
.note-panel.active { display: block; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.15rem;
    font-size: .85rem;
    font-weight: 600;
    font-family: var(--font-main);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #5558E6; }

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(248, 113, 113, .25);
}
.btn-danger:hover {
    background: var(--danger-glow);
}

.btn-sm {
    padding: .35rem .7rem;
    font-size: .78rem;
}

.btn-group {
    display: flex;
    gap: .5rem;
    margin-top: 1.25rem;
}

/* --------------- Login --------------- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.login-title {
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: .25rem;
    letter-spacing: -.02em;
}

.login-subtitle {
    text-align: center;
    font-size: .82rem;
    color: var(--text-dim);
    margin-bottom: 1.75rem;
}

.login-brand {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* --------------- Flash Messages --------------- */
.flash {
    padding: .65rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 500;
    border: 1px solid;
}

.flash-error {
    background: var(--danger-glow);
    border-color: rgba(248, 113, 113, .3);
    color: var(--danger);
}

.flash-success {
    background: var(--success-glow);
    border-color: rgba(52, 211, 153, .3);
    color: var(--success);
}

/* --------------- Note Modal --------------- */
.note-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
}

.note-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.note-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    transition: transform 200ms;
}

.note-modal-overlay.active .note-modal {
    transform: translateY(0);
}

.note-modal-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.note-modal-content {
    font-size: .88rem;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.note-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
}

/* --------------- Rooms List --------------- */
.room-list-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: .35rem;
    transition: var(--transition);
}

.room-list-item:hover {
    background: var(--bg-card-hover);
}

.room-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.room-list-name {
    flex: 1;
    font-weight: 600;
    font-size: .88rem;
}

.room-list-count {
    font-family: var(--font-mono);
    font-size: .75rem;
    color: var(--text-dim);
}

/* --------------- History --------------- */
.history-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
}

.history-date {
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--text-dim);
    min-width: 85px;
}

.history-task { font-weight: 600; flex: 1; }
.history-user { color: var(--text-muted); font-size: .75rem; }

/* --------------- Color Picker --------------- */
.color-options {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,.3); }

/* --------------- Users Table --------------- */
.users-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 .25rem;
}

.users-table th {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    padding: .5rem 1rem;
    text-align: left;
}

.users-table td {
    padding: .65rem 1rem;
    background: var(--bg-card);
    font-size: .85rem;
}

.users-table tr td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.users-table tr td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* --------------- Responsive --------------- */
@media (max-width: 640px) {
    .topbar { padding: 0 .75rem; }
    .topbar-brand { font-size: .95rem; }
    .main-content { padding: 1rem .75rem 2rem; }
    .stats-bar { gap: .5rem; }
    .stat-card { padding: .75rem; min-width: 100px; }
    .stat-value { font-size: 1.3rem; }
    .task-card { padding: .6rem .75rem; gap: .5rem; }
    .form-row { grid-template-columns: 1fr; }
    .topbar-nav { gap: .15rem; }
    .topbar-nav a, .topbar-nav button { padding: .35rem .5rem; font-size: .75rem; }
    .task-actions { gap: .3rem; }
    .badge { font-size: .62rem; padding: .15rem .4rem; }
}
