/* ============================================================================
   CSS CUSTOM PROPERTIES — Light/Dark via data-theme
   ============================================================================ */
:root {
    --bg: #ffffff;
    --bg-secondary: #f9f9f9;
    --bg-header: #f0f0f0;
    --text: #333333;
    --text-muted: #666666;
    --border: #cccccc;
    --link: #0066cc;
    --btn-bg: #e0e0e0;
    --btn-bg-hover: #d0d0d0;
    --btn-border: #cccccc;
    --reply-border: #cccccc;
    --toast-bg: #ffffff;
    --status-yes-bg: #a7d8a7; --status-yes-text: #0f5132;
    --status-no-bg: #f8d7da;  --status-no-text: #721c24;
    --status-out-bg: #ffe5e5; --status-out-text: #721c24;
    --status-ask-bg: #fff3cd; --status-ask-text: #856404;
    --status-unsicher-bg: #ffcc80; --status-unsicher-text: #bf360c;
    --status-empty-bg: #f0fdf4;
}
[data-theme="dark"] {
    --bg: #141414;
    --bg-secondary: #1c1c1c;
    --bg-header: #222222;
    --text: #e0e0e0;
    --text-muted: #606060;
    --border: #2e2e2e;
    --link: #5599ff;
    --btn-bg: #282828;
    --btn-bg-hover: #323232;
    --btn-border: #383838;
    --reply-border: #383838;
    --toast-bg: #1c1c1c;
    --status-yes-bg: #081a0e; --status-yes-text: #4ade80;
    --status-no-bg: #1c0808;  --status-no-text: #f87171;
    --status-out-bg: #160808; --status-out-text: #e08080;
    --status-ask-bg: #141000; --status-ask-text: #fbbf24;
    --status-unsicher-bg: #180c00; --status-unsicher-text: #fb923c;
    --status-empty-bg: #141414;
}

/* ============================================================================
   BASE
   ============================================================================ */
:root {
    --nav-chrome-w: 88px;
    --page-title-size: 1.35rem;
    --page-max-width: 800px;
    --page-max-width-calendar: 1200px;
    --page-max-width-admin: 1100px;
}
body {
    font-family: Arial, sans-serif;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 10px;
    padding-top: 60px;
    background: var(--bg);
    color: var(--text);
}
/* Login / Confirm: kein fixed Nav-Chrome */
body.no-nav { padding-top: 16px; }
h1, h2 { color: var(--text); }
h1 {
    font-size: var(--page-title-size);
    font-weight: bold;
    line-height: 1.25;
    margin: 0 0 12px;
}
body:not(.no-nav) h1,
body:not(.no-nav) .page-header {
    padding-right: var(--nav-chrome-w);
    box-sizing: border-box;
}
small { color: var(--text-muted); }
textarea {
    width: 100%;
    box-sizing: border-box;
    resize: none;
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
input[type="submit"] {
    padding: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
}
input[type="text"][name="input"] { text-transform: uppercase; }

/* ============================================================================
   PAGE HEADER
   ============================================================================ */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
}
.page-header h1,
body:not(.no-nav) .page-header h1 {
    margin: 0;
    flex: 0 0 auto;
    padding-right: 0;
    max-width: 100%;
}
@media (max-width: 600px) {
    .page-header { justify-content: center; text-align: center; }
    .page-header h1 { width: 100%; }
}

/* ============================================================================
   NAV PILLS (Blog/Partien Tab-Switch)
   ============================================================================ */
.nav-pills {
    display: flex;
    gap: 6px;
    align-items: center;
}
.nav-pill {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    border: 0.5px solid var(--border);
    background: var(--bg);
    transition: background 0.15s, color 0.15s;
}
.nav-pill:hover {
    background: var(--bg-header);
    color: var(--text);
}
.nav-pill.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* ============================================================================
   POSTS
   ============================================================================ */
.post {
    border: 1px solid var(--border);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    background: var(--bg);
}
.replies-container {
    border: 1px solid var(--border);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    background: var(--bg-secondary);
}
.reply {
    margin-bottom: 10px;
    padding: 10px;
    border-left: 3px solid var(--reply-border);
    background: var(--bg);
}
.reply-author { font-weight: bold; margin-bottom: 5px; }
.post h2 a { text-decoration: none; color: var(--link); }
.post-author { font-style: italic; color: var(--text-muted); margin-bottom: 10px; }
.post-actions { margin-top: 10px; }
.post-actions a:not(.icon-btn),
.post-actions button:not(.icon-btn) {
    margin-right: 10px;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 3px;
    display: inline-block;
    line-height: 1.2;
    font-size: inherit;
    border: none;
    cursor: pointer;
    flex: 1;
    text-align: center;
    vertical-align: middle;
}
@media (max-width: 600px) {
    body { padding: 5px; padding-top: 60px; }
    body.no-nav { padding-top: 16px; }
    .post { padding: 10px; }
    .replies-container { padding: 10px; }
    .post-actions a:not(.icon-btn),
    .post-actions button:not(.icon-btn) { display: block; margin: 5px 0; width: 100%; text-align: center; }
}
@media (min-width: 601px) { .post-actions { display: flex; gap: 10px; } }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.icon-btn {
    padding: 2px 4px;
    font-size: 1em;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    border: 0.5px solid var(--btn-border);
    line-height: 1;
    margin-right: 3px;
}
.icon-btn-edit { background: transparent; color: var(--text); border-color: var(--btn-border); }
.icon-btn-edit:hover { background: var(--btn-bg); }
.icon-btn-action { background: transparent; color: var(--text); border-color: var(--btn-border); }
.icon-btn-action:hover { background: var(--btn-bg); }
.icon-btn-delete { background: transparent; color: #e74c3c; border-color: var(--btn-border); }
.icon-btn-delete:hover { background: var(--btn-bg); }

/* ============================================================================
   PREVIEW (serienmail)
   ============================================================================ */
.preview-container {
    border: 1px solid var(--border);
    margin-top: 10px;
    background: var(--bg-secondary);
}
.preview-header {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-header);
}
.preview-header label { display: inline-block; margin-right: 10px; font-weight: bold; }
.preview-header button {
    padding: 3px 6px;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text);
}
.preview-header button:hover { background: var(--btn-bg-hover); }
#content { padding: 10px; min-height: 100px; margin: 0; border: none; overflow: hidden; }
#preview { padding: 10px; min-height: 100px; }

/* ============================================================================
   REMARKS MODAL (base in spieltage.css; mobile tweak)
   ============================================================================ */
@media (max-width: 600px) {
    .remarks-modal-content { margin: 5% auto; width: 95%; border-radius: 5px; }
    .remarks-modal-header { padding: 15px; }
    .remarks-modal-header h3 { font-size: 1.1em; }
    .remarks-modal-close { font-size: 24px; }
    .remarks-modal-body { padding: 15px; }
    .remarks-modal-body textarea { min-height: 60px; padding: 8px; }
    .remarks-modal-footer { padding: 15px; text-align: center; }
    .remarks-modal .btn { padding: 8px 16px; margin: 5px; display: block; width: 100%; box-sizing: border-box; }
}

/* ============================================================================
   STATUS COLORS (shared spieltage + confirm)
   ============================================================================ */
.status-empty    { background: var(--status-empty-bg) !important; }
.status-ol,
.status-no       { background: var(--status-no-bg) !important; color: var(--status-no-text); }
.status-out      { background: var(--status-out-bg) !important; color: var(--status-out-text); }
.status-ask      { background: var(--status-ask-bg) !important; color: var(--status-ask-text); }
.status-unsicher { background: var(--status-unsicher-bg) !important; color: var(--status-unsicher-text); }
.status-unbesetzt{ background: var(--status-no-bg) !important; color: var(--status-no-text); }
.status-yes      { background: var(--status-yes-bg) !important; color: var(--status-yes-text); }

/* ============================================================================
   TOAST SYSTEM
   ============================================================================ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--toast-bg);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 16px 20px;
    max-width: 350px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid;
    position: relative;
    color: var(--text);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(400px); opacity: 0; }
.toast-success { border-left-color: #4CAF50; background: color-mix(in srgb, var(--bg) 90%, #4CAF50 10%); }
.toast-error   { border-left-color: #f44336; background: color-mix(in srgb, var(--bg) 90%, #f44336 10%); }
.toast-warning { border-left-color: #ff9800; background: color-mix(in srgb, var(--bg) 90%, #ff9800 10%); }
.toast-icon { font-size: 18px; flex-shrink: 0; line-height: 0; display: flex; align-items: center; }
.toast-success .toast-icon { color: #4CAF50; }
.toast-error .toast-icon   { color: #f44336; }
.toast-warning .toast-icon { color: #ff9800; }
.toast-content { flex: 1; font-size: 14px; line-height: 1.4; color: var(--text); }
.toast-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }
@media (max-width: 600px) {
    .toast-container { left: 10px; right: 10px; bottom: 10px; }
    .toast { min-width: auto; max-width: none; }
    .toast, .toast.hide { transform: translateY(100px); }
    .toast.show { transform: translateY(0); }
}

/* ============================================================================
   HAMBURGER + NAV DRAWER (rechts)
   ============================================================================ */
#nav-chrome {
    position: fixed;
    top: 12px;
    right: max(12px, calc((100vw - var(--page-max-width)) / 2));
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
}
body.view-matrix #nav-chrome,
body.view-cards #nav-chrome {
    right: max(12px, calc((100vw - var(--page-max-width-calendar)) / 2));
}
body.admin-page #nav-chrome {
    right: max(12px, calc((100vw - var(--page-max-width-admin)) / 2));
}
#hamburger {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text);
    line-height: 0;
}
#hamburger:hover { background: var(--btn-bg); }
#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1200;
}
#nav-overlay.open { display: block; }
#nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    box-sizing: border-box;
    width: min(280px, 100vw);
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -2px 0 16px rgba(0,0,0,0.15);
    overflow-x: hidden;
    overflow-y: auto;
}
#nav-drawer.open { transform: translateX(0); }
#nav-drawer .nav-header,
#nav-drawer .nav-items,
#nav-drawer .nav-footer,
#nav-drawer .nav-item,
#nav-drawer .nav-user {
    box-sizing: border-box;
    max-width: 100%;
}
.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.nav-title { font-weight: bold; font-size: 1em; color: var(--text); }
.nav-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 0;
    border-radius: 4px;
}
.nav-close:hover { background: var(--btn-bg); color: var(--text); }
.nav-items { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95em;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--btn-bg); }
.nav-item.nav-active { background: var(--btn-bg); font-weight: bold; }
.nav-item-sub {
    padding-left: 42px;
    font-size: 0.9em;
    color: var(--text-muted);
    gap: 10px;
}
.nav-item-sub.nav-active { color: var(--text); }
.nav-footer { padding: 8px 0 16px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 16px; }
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 0.85em;
    color: var(--text-muted);
}
/* Darkmode icon visibility */
.icon-sun { display: none; }
.icon-moon { display: inline; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
/* Lucide base */
.lucide { vertical-align: middle; flex-shrink: 0; }

/* Spinner animation for loader-2 */
@keyframes sgl-spin { to { transform: rotate(360deg); } }
.lucide-spin { animation: sgl-spin 1s linear infinite; transform-origin: center; }

/* User-Badge links vom Hamburger */
#user-status-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    line-height: 0;
    color: #4CAF50;
    cursor: default;
}

/* ============================================================================
   PARTIEN-LISTE
   ============================================================================ */
.partien-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}
.partien-search {
    flex: 1 1 200px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    box-sizing: border-box;
}
.partien-search:focus {
    outline: none;
    border-color: var(--text-muted);
}
.partien-count {
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}
.partien-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}
.partie-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    text-decoration: none;
    color: var(--text);
    min-height: 52px;
    box-sizing: border-box;
    overflow: visible;
}
.partie-card:hover {
    background: var(--bg-header);
    border-color: var(--text-muted);
}
.partie-thumb {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--bg-secondary);
    z-index: 1;
}
.partie-thumb svg {
    display: block;
    width: 44px;
    height: 44px;
}
@media (hover: hover) and (pointer: fine) {
    .partie-thumb:hover {
        z-index: 40;
        overflow: visible;
        border-color: transparent;
        background: transparent;
    }
    .partie-thumb:hover svg {
        position: absolute;
        left: 0;
        top: 50%;
        width: 200px;
        height: 200px;
        transform: translateY(-50%);
        border: 1px solid var(--border);
        border-radius: 3px;
        background: var(--bg);
    }
}
.partie-card-body {
    flex: 1;
    min-width: 0;
}
.partie-card-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.partie-card-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.partie-result {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text);
    background: var(--bg-secondary);
    line-height: 1.2;
}
.partie-result.result-white { border-color: var(--text-muted); }
.partie-result.result-black { border-color: var(--text-muted); }
.partie-result.result-draw { color: var(--text-muted); }
.partie-result.result-unknown { color: var(--text-muted); font-weight: normal; }
.partien-empty { margin: 16px 0; color: var(--text-muted); font-size: 14px; }
@media (max-width: 480px) {
    .partie-card {
        align-items: flex-start;
    }
    .partie-card-sub {
        white-space: normal;
    }
}

/* ============================================================================
   BACK NAV / BREADCRUMB
   ============================================================================ */
.back-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
}
.back-nav a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    min-height: 28px;
}
.back-nav a:hover { color: var(--link); }
.back-nav svg { flex-shrink: 0; }
.back-nav-sep { color: var(--text-muted); opacity: 0.5; user-select: none; }
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.3;
}
.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}
.breadcrumb a:hover { color: var(--link); }
.breadcrumb .sep { opacity: 0.5; user-select: none; }
.breadcrumb .current {
    color: var(--text);
    font-weight: 500;
    max-width: 14em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}