/* Keuzehulp Admin — SKAPA Global house style */

:root {
    --bpw-orange: #24CB65;
    --bpw-orange-dark: #1BA854;
    --bpw-dark: #021D49;
    --bpw-gray: #6B7280;
    --bpw-light: #F9FAFB;
    --bpw-border: #E5E7EB;
    --bpw-success: #059669;
    --bpw-error: #DC2626;
    --bpw-white: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bpw-light);
    color: var(--bpw-dark);
    min-height: 100vh;
}

/* ============ Login ============ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--bpw-white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--bpw-orange);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--bpw-gray);
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bpw-dark);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--bpw-border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--bpw-orange);
    box-shadow: 0 0 0 3px rgba(232,119,34,0.1);
}

/* ============ Buttons ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--bpw-orange);
    color: var(--bpw-white);
}

.btn-primary:hover {
    background: var(--bpw-orange-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bpw-white);
    color: var(--bpw-dark);
    border: 1px solid var(--bpw-border);
}

.btn-secondary:hover {
    background: var(--bpw-light);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

/* ============ Alerts ============ */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.alert-error {
    background: #FEF2F2;
    color: var(--bpw-error);
    border: 1px solid #FECACA;
}

/* ============ Admin Layout — Sidebar ============ */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--bpw-dark);
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s, transform 0.3s;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 30;
}
.admin-sidebar.collapsed {
    margin-left: -240px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--bpw-orange);
}
.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.85;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}
.sidebar-item.active {
    background: rgba(255,255,255,0.12);
    color: white;
    border-left-color: var(--bpw-orange);
}
.sidebar-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}
.sidebar-footer {
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-main {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bpw-white);
    border-bottom: 1px solid var(--bpw-border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.hamburger-btn {
    background: none;
    border: 1px solid var(--bpw-border);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--bpw-dark);
    transition: all 0.15s;
}
.hamburger-btn:hover {
    background: var(--bpw-light);
}

.admin-page {
    padding: 1.5rem;
    max-width: 1000px;
}
.admin-page-header {
    margin-bottom: 1.25rem;
}
.admin-page-header h2 {
    font-size: 1.3rem;
    color: var(--bpw-dark);
}

/* Legacy container (for non-sidebar pages) */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.user-badge {
    background: var(--bpw-light);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--bpw-gray);
    border: 1px solid var(--bpw-border);
}

.auth-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.auth-bar-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    line-height: 1.25;
    max-width: 240px;
}

.auth-bar-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bpw-dark);
}

.auth-bar-email {
    font-size: 0.72rem;
    color: var(--bpw-gray);
    word-break: break-all;
}

.auth-bar-logout {
    margin: 0;
}

/* Mobile sidebar */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(0);
        z-index: 100;
    }
    .admin-sidebar.collapsed {
        transform: translateX(-240px);
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
    }
    .admin-page {
        padding: 1rem;
    }
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bpw-white);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid var(--bpw-border);
    border-top: 3px solid var(--bpw-orange);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #F0FDF4;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--bpw-orange);
    line-height: 1.2;
    word-break: break-all;
}

.stat-number-sm {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--bpw-dark);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--bpw-gray);
    margin-top: 0.1rem;
}

/* Section cards (replaces .actions) */

.section-card,
.actions {
    background: var(--bpw-white);
    border-radius: 12px;
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid var(--bpw-border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--bpw-border);
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bpw-dark);
    margin: 0;
}

.actions h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.actions p {
    color: var(--bpw-gray);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.result-box {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    background: var(--bpw-light);
    border: 1px solid var(--bpw-border);
}

.result-box.success {
    background: #F0FDF4;
    border-color: #BBF7D0;
    color: var(--bpw-success);
}

.result-box.error {
    background: #FEF2F2;
    border-color: #FECACA;
    color: var(--bpw-error);
}

/* ============ Table ============ */

.kh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.kh-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--bpw-border);
    color: var(--bpw-gray);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kh-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--bpw-border);
    vertical-align: middle;
}

.kh-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-draft {
    background: #FEF3C7;
    color: #065F46;
}

.status-live {
    background: #D1FAE5;
    color: #065F46;
}

/* ============ Modal ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--bpw-white);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-card h2 {
    margin-bottom: 1.25rem;
    font-size: 1.2rem;
}

/* ============ Toast ============ */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--bpw-white);
    background: var(--bpw-dark);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.success { background: var(--bpw-success); }
.toast.error { background: var(--bpw-error); }

/* ============ Save feedback on the button ============ */
/* Button shows "Saving…" with a spinner and then "✓ Saved", so a
   save click is visibly processed (and doesn't accidentally fire twice). */

.btn.btn-saving {
    opacity: 0.85;
    cursor: progress;
}

.btn.btn-saved,
.btn.btn-saved:disabled {
    background: var(--bpw-success);
    color: var(--bpw-white);
    opacity: 1;
}

.btn.btn-save-failed,
.btn.btn-save-failed:disabled {
    background: var(--bpw-error);
    color: var(--bpw-white);
    opacity: 1;
}

.btn-spinner {
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-right: 0.45em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-spinner { animation: none; opacity: 0.6; }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Table enhancements ============ */

.kh-table tr:hover td {
    background: var(--bpw-light);
}

.kh-table td {
    transition: background 0.15s;
}

/* ============ Status Indicators ============ */

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.35rem;
    flex-shrink: 0;
}

.status-dot-green {
    background: var(--bpw-success);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.15);
}

.status-dot-red {
    background: var(--bpw-error);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.15);
}

.status-dot-yellow {
    background: #F59E0B;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}

.status-dot-gray {
    background: var(--bpw-gray);
    box-shadow: 0 0 0 3px rgba(107,114,128,0.15);
}

/* ============ Status Overview ============ */

.status-system {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.15rem;
    background: var(--bpw-light);
    border-radius: 8px;
    font-size: 0.88rem;
    border: 1px solid var(--bpw-border);
}

.status-system-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.status-store-card {
    border: 1px solid var(--bpw-border);
    border-radius: 10px;
    padding: 1.25rem;
    background: var(--bpw-light);
    transition: box-shadow 0.2s;
}

.status-store-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.status-store-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.status-store-header strong {
    flex: 1;
    font-size: 0.95rem;
}

.status-store-meta {
    font-size: 0.85rem;
    color: var(--bpw-gray);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.status-store-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ============ API Connections ============ */

.connectie-card {
    border: 1px solid var(--bpw-border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    background: var(--bpw-light);
    transition: box-shadow 0.2s;
}

.connectie-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.connectie-card:last-child {
    margin-bottom: 0;
}

.connectie-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.connectie-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connectie-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.connectie-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bpw-gray);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.connectie-field input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--bpw-border);
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: 'Consolas', 'Monaco', monospace;
    background: var(--bpw-white);
    transition: border-color 0.2s;
}

.connectie-field input:focus {
    outline: none;
    border-color: var(--bpw-orange);
    box-shadow: 0 0 0 3px rgba(232,119,34,0.1);
}

.connectie-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.connectie-result {
    display: inline-block;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
}

.connectie-result.success {
    background: #D1FAE5;
    color: #065F46;
}

.connectie-result.error {
    background: #FEF2F2;
    color: var(--bpw-error);
}

.connectie-coming-soon {
    background: #FEF3C7;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: #065F46;
    font-size: 0.88rem;
}

/* ============ Notification Bell ============ */

.alert-bell {
    position: relative;
    background: none;
    border: 1px solid var(--bpw-border);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    transition: background 0.2s;
}

.alert-bell:hover {
    background: var(--bpw-light);
}

.alert-bell-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--bpw-error);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.alert-bell-badge:empty,
.alert-bell-badge[data-count="0"] {
    display: none;
}

/* ============ Alert Panel ============ */

.alert-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 420px;
    background: var(--bpw-white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid var(--bpw-border);
    z-index: 999;
    overflow: hidden;
    display: none;
}

.alert-panel.open {
    display: block;
}

.alert-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--bpw-border);
    background: var(--bpw-light);
}

.alert-panel-header h3 {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 0;
}

.alert-panel-body {
    max-height: 340px;
    overflow-y: auto;
}

.alert-panel-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--bpw-gray);
    font-size: 0.88rem;
}

.alert-item {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--bpw-border);
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.alert-item:hover {
    background: var(--bpw-light);
}

.alert-item:last-child {
    border-bottom: none;
}

.alert-item.severity-critical {
    border-left-color: var(--bpw-error);
}

.alert-item.severity-warning {
    border-left-color: #F59E0B;
}

.alert-item.severity-info {
    border-left-color: #3B82F6;
}

.alert-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.alert-item-type {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.alert-item.severity-critical .alert-item-type { color: var(--bpw-error); }
.alert-item.severity-warning .alert-item-type { color: #D97706; }
.alert-item.severity-info .alert-item-type { color: #2563EB; }

.alert-item-time {
    font-size: 0.72rem;
    color: var(--bpw-gray);
}

.alert-item-message {
    font-size: 0.84rem;
    color: var(--bpw-dark);
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.alert-item-store {
    font-size: 0.75rem;
    color: var(--bpw-gray);
    margin-bottom: 0.5rem;
}

.alert-item-actions {
    display: flex;
    gap: 0.5rem;
}

.alert-item-actions button {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    border: 1px solid var(--bpw-border);
    background: var(--bpw-white);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}

.alert-item-actions button:hover {
    background: var(--bpw-light);
    border-color: var(--bpw-orange);
    color: var(--bpw-orange);
}

/* ============ Links ============ */

a.btn {
    text-decoration: none;
}

/* ============ Responsive ============ */

@media (max-width: 640px) {
    .connectie-fields {
        grid-template-columns: 1fr;
    }
    .status-grid {
        grid-template-columns: 1fr;
    }
    .connectie-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .alert-panel {
        width: 320px;
        right: -60px;
    }
}
