/* ═══════════════════════════════════════════════════════════
   Bolotyuk CRM — Dark Sidebar + Light Content
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Sidebar (dark) */
    --sb-bg: #12131d;
    --sb-border: #2a2d3e;
    --sb-text: #e4e6f0;
    --sb-text-dim: #8b8fa3;
    --sb-text-muted: #5d6178;
    --sb-hover: #1f2237;

    /* Main (light) */
    --bg-primary: #f4f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f1f4;
    --bg-hover: #f7f7f9;
    --bg-topbar: #ffffff;
    --border: #e2e4ea;
    --border-light: #d0d3dc;
    --text-primary: #1a1c28;
    --text-secondary: #5a5e72;
    --text-muted: #8b8fa3;

    /* Accent */
    --accent: #7c5cfc;
    --accent-hover: #6a4ce0;
    --accent-light: rgba(124, 92, 252, 0.10);
    --accent-light-solid: #eeebff;

    /* Status */
    --green: #16a34a;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --yellow: #ca8a04;
    --yellow-bg: #fefce8;
    --blue: #2563eb;
    --blue-bg: #eff6ff;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

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

/* ── Layout ─────────────────────────────────────────────── */

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

/* ── Sidebar (DARK) ─────────────────────────────────────── */

.sidebar {
    width: 240px;
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--sb-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo h1 span {
    color: var(--accent);
}

.sidebar-logo small {
    display: block;
    color: var(--sb-text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sb-text-dim);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--sb-hover);
    color: var(--sb-text);
}

.nav-item.active {
    background: rgba(124, 92, 252, 0.15);
    color: var(--accent);
}

.nav-item .icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sb-border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sb-text-muted);
    font-size: 13px;
    padding: 8px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar-footer a:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.12);
}

/* ── Main content (LIGHT) ───────────────────────────────── */

.main {
    flex: 1;
    margin-left: 240px;
    padding: 0;
    background: var(--bg-primary);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-topbar);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.topbar h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.content {
    padding: 24px 32px;
}

/* ── Cards ──────────────────────────────────────────────── */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.stat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .icon-bg {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.icon-purple { background: var(--accent-light-solid); }
.icon-green { background: var(--green-bg); }
.icon-blue { background: var(--blue-bg); }
.icon-yellow { background: var(--yellow-bg); }

/* ── Tables ─────────────────────────────────────────────── */

.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.table-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

td .main-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Badges ─────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--accent-light-solid); color: var(--accent); }
.badge-muted { background: #f0f1f4; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(124, 92, 252, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
    box-shadow: 0 2px 6px rgba(124, 92, 252, 0.35);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px 8px;
    min-width: 32px;
    justify-content: center;
}

/* ── Forms ──────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b8fa3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* ── Modal / Drawer ─────────────────────────────────────── */

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

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Detail Page ────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.detail-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: var(--text-muted);
    font-size: 13px;
}

.detail-row .value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}

/* ── Chat / Messages ────────────────────────────────────── */

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--bg-input);
}

.chat-msg {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: var(--shadow);
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg.system {
    align-self: center;
    background: var(--yellow-bg);
    color: var(--yellow);
    font-size: 12px;
    max-width: 90%;
}

.chat-msg .time {
    font-size: 11px;
    opacity: 0.5;
    margin-top: 4px;
}

/* ── Key code ───────────────────────────────────────────── */

.key-code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: var(--accent-light-solid);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent);
    border: 1px solid rgba(124, 92, 252, 0.15);
}

/* ── Login Page (stays dark) ────────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0f1117;
}

.login-box {
    background: #1a1c2a;
    border: 1px solid #2a2d3e;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.login-box h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
    color: #e4e6f0;
}

.login-box h1 span {
    color: var(--accent);
}

.login-box p {
    text-align: center;
    color: #5d6178;
    margin-bottom: 24px;
    font-size: 13px;
}

.login-box .error {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    text-align: center;
}

.login-box .form-group label {
    color: #8b8fa3;
}

.login-box .form-control {
    background: #1e2033;
    border-color: #2a2d3e;
    color: #e4e6f0;
}

.login-box .form-control::placeholder {
    color: #5d6178;
}

.login-box .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
}

.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

/* ── Alerts ─────────────────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid #fecaca;
}

/* ── Status colors ──────────────────────────────────────── */

.status-new { color: var(--blue); }
.status-searching { color: var(--yellow); }
.status-quoted { color: var(--accent); }
.status-confirmed { color: var(--green); }
.status-ordered { color: var(--blue); }
.status-delivered { color: var(--green); }
.status-completed { color: var(--green); }
.status-cancelled { color: var(--red); }

/* ── Empty state ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
}

/* ── Misc ───────────────────────────────────────────────── */

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }

.copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── Burger button ──────────────────────────────────────── */

.burger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.burger-btn:hover {
    background: var(--bg-input);
}

.burger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Sidebar overlay (mobile) ──────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .burger-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar h2 {
        font-size: 16px;
    }

    .topbar-actions {
        gap: 4px;
    }

    .topbar-actions .btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .content {
        padding: 16px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-wrap {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    /* Modal fullscreen on mobile */
    .modal {
        width: 100%;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-backdrop {
        align-items: flex-end;
    }

    .chat-msg {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions .btn-sm {
        padding: 4px 6px;
        font-size: 10px;
    }
}
