/* ============================================================
   BNI Sync Dashboard – Stylesheet
   Dark theme, BNI Red (#cc0000)
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --red: #cc0000;
    --red2: #e00000;
    --bg: #111113;
    --surface: #1c1c1f;
    --card: #222226;
    --border: #2e2e33;
    --text: #f0f0f2;
    --muted: #888;
    --green: #22c55e;
    --blue: #3b82f6;
    --orange: #f59e0b;
    --radius: 10px;
}

html,
body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ── Layout ─────────────────────────────────────────────── */
body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.sidebar-logo {
    font-size: 22px;
    font-weight: 800;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.logo-bni {
    color: var(--red);
}

.logo-sync {
    color: var(--text);
    margin-left: 4px;
}

nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--card);
    color: var(--text);
}

.nav-item.active {
    background: rgba(204, 0, 0, 0.15);
    color: var(--red);
}

.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
}

.datetime {
    font-size: 12px;
    color: var(--muted);
}

/* ── Pages ──────────────────────────────────────────────── */
.page {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    flex-direction: column;
    gap: 20px;
}

.page.active {
    display: flex;
}

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: #444;
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
}

.stat-card-icon.green {
    background: rgba(34, 197, 94, 0.15);
}

.stat-card-icon.blue {
    background: rgba(59, 130, 246, 0.15);
}

.stat-card-icon.red {
    background: rgba(204, 0, 0, 0.15);
}

.stat-card-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.stat-card-label {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-sub {
    font-size: 11px;
    color: #555;
}

/* ── Bottom Row ─────────────────────────────────────────── */
.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.full-card {
    flex: 1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
}

.card-badge {
    font-size: 11px;
    color: var(--muted);
    background: var(--surface);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.card-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Skip Toggle ────────────────────────────────────────── */
.skip-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(204, 0, 0, 0.08);
    border: 1px solid rgba(204, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px 14px;
}

.skip-label strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
}

.skip-label small {
    font-size: 11px;
    color: var(--muted);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ── Toggle Items ───────────────────────────────────────── */
.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

/* ── Toggle Switch ──────────────────────────────────────── */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #333;
    border-radius: 24px;
    transition: background 0.2s;
}

.slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

input:checked+.slider {
    background: var(--red);
}

input:checked+.slider::before {
    transform: translateX(20px);
}

.toggle-large {
    width: 56px;
    height: 30px;
}

.toggle-large .slider::before {
    height: 22px;
    width: 22px;
}

.toggle-large input:checked+.slider::before {
    transform: translateX(26px);
}

/* ── Actions Card ───────────────────────────────────────── */
.actions-card {
    gap: 10px;
}

.last-sync-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    padding-top: 4px;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--red2);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary.big {
    padding: 12px;
    font-size: 14px;
}

.btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-outline:hover {
    border-color: var(--red);
    color: var(--red);
}

.btn-outline.big {
    padding: 12px;
    font-size: 14px;
}

/* ── Status Msg ─────────────────────────────────────────── */
.status-msg {
    font-size: 12px;
    color: var(--green);
    min-height: 18px;
    text-align: center;
}

.status-msg.error {
    color: #f87171;
}

/* ── Visitor Table ──────────────────────────────────────── */
.search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text);
    font-size: 12px;
    outline: none;
    width: 200px;
}

.search-input:focus {
    border-color: var(--red);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.empty-row {
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

.badge-green {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-orange {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-red {
    background: rgba(204, 0, 0, 0.15);
    color: #f87171;
}

.badge-gray {
    background: rgba(136, 136, 136, 0.1);
    color: var(--muted);
}

/* ── Settings ───────────────────────────────────────────── */
.settings-body {
    gap: 16px;
    max-width: 400px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-group input,
.setting-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.setting-group input:focus,
.setting-group select:focus {
    border-color: var(--red);
}

.setting-group select option {
    background: var(--surface);
}

/* ── Log ────────────────────────────────────────────────── */
.log-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-entry-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.log-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.log-entry-time {
    font-size: 12px;
    color: var(--muted);
}

.log-entry-result {
    font-size: 12px;
    font-family: 'Consolas', monospace;
    color: #aaa;
    white-space: pre-wrap;
}

/* ── Dot ────────────────────────────────────────────────── */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.green {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.dot.orange {
    background: var(--orange);
}

.dot.red {
    background: var(--red);
}

/* ── Delete Feature ────────────────────────────────────────── */
.btn-load-visitors {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-load-visitors svg {
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.btn-load-visitors:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.btn-load-visitors:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.delete-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--muted);
}

/* Delete page scrolling fix */
#page-loeschen .full-card {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#page-loeschen .card-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(204, 0, 0, 0.1);
    border: 1px solid rgba(204, 0, 0, 0.3);
    color: #f87171;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-delete:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn-delete:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 420px;
    max-width: 90vw;
    overflow: hidden;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 18px 20px;
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 18px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
}

.modal-body strong {
    color: var(--text);
}

.modal-warning {
    color: #f87171;
    font-size: 12px;
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.modal-actions .btn-outline {
    width: auto;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-danger:hover {
    background: var(--red2);
}

.btn-danger:active {
    transform: scale(0.97);
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Delete row animation */
.delete-row-fade {
    animation: rowFade 0.4s ease-out forwards;
}

@keyframes rowFade {
    to { opacity: 0; transform: translateX(20px); height: 0; padding: 0; }
}