/* ── Pipedrive-Style CRM Layout ─────────────────────── */

:root {
    --sidebar-width: 220px;
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: #16213e;
    --sidebar-active: #0f3460;
    --sidebar-text: #a8a8b3;
    --sidebar-text-active: #ffffff;
    --sidebar-brand: #4fc3f7;
    --topbar-height: 56px;
    --content-bg: #f4f5f7;
    --accent: #317ae2;
    --accent-hover: #2563c4;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--content-bg);
    color: #333;
    font-size: 14px;
}

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

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

/* ── Sidebar ─────────────────────────────────────────── */

.crm-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand a {
    text-decoration: none;
    display: block;
}

.sidebar-logo {
    width: 100%;
    max-width: 160px;
    height: auto;
    border-radius: 6px;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    margin: 0;
    flex: 1;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-item a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-item.active a {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-brand);
}

.sidebar-item a i {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    font-size: 13px;
    margin-bottom: 8px;
}

.sidebar-user i {
    font-size: 18px;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 0;
    transition: color 0.15s;
}

.sidebar-logout:hover {
    color: #e74c3c;
}

/* ── Main Content ────────────────────────────────────── */

.crm-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.crm-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.crm-page-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

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

.crm-content {
    padding: 24px;
    flex: 1;
}

/* ── Sidebar Toggle (Mobile) ────────────────────────── */

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 22px;
    color: #333;
    cursor: pointer;
    padding: 4px;
}

@media (max-width: 991.98px) {
    .crm-sidebar {
        transform: translateX(-100%);
    }
    .crm-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .crm-main {
        margin-left: 0;
    }
}

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

.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 14px;
}

/* ── KPI Cards (Dashboard) ───────────────────────────── */

.kpi-card {
    border-radius: 10px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.kpi-card .kpi-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    opacity: 0.2;
}

.kpi-card h6 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 8px;
}

.kpi-card .kpi-value {
    font-size: 26px;
    font-weight: 700;
}

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

.table {
    font-size: 14px;
}

.table thead th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #666;
    border-bottom: 2px solid #dee2e6;
    padding: 10px 12px;
}

.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #edf2ff;
}

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

.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

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

.badge {
    font-weight: 500;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}

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

.form-control, .form-select {
    font-size: 14px;
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(49, 122, 226, 0.15);
}

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

.alert {
    border-radius: 8px;
    font-size: 14px;
    border: none;
}

/* ── Login Page ──────────────────────────────────────── */

.crm-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #16213e 100%);
    flex-direction: column;
}

.crm-login-wrapper .card {
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    min-width: 380px;
}

.crm-login-wrapper .card-body {
    padding: 40px;
}

.crm-login-wrapper .card-title {
    color: var(--sidebar-bg);
}

/* ── Pipeline Bars ───────────────────────────────────── */

.pipeline-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

/* ── Scrollbar ───────────────────────────────────────── */

.crm-sidebar::-webkit-scrollbar {
    width: 4px;
}

.crm-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.crm-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* ── Kanban Board ────────────────────────────────────── */

.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: calc(100vh - var(--topbar-height) - 80px);
    align-items: flex-start;
}

.kanban-column {
    min-width: 280px;
    max-width: 280px;
    background: #eef0f4;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.kanban-column-header {
    padding: 12px 14px;
    border-top: 3px solid #6c757d;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
}

.kanban-column-title {
    color: #333;
}

.kanban-column-count {
    background: rgba(0,0,0,0.1);
    color: #555;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-cards {
    padding: 8px;
    min-height: 60px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kanban-card {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: grab;
    transition: box-shadow 0.15s, transform 0.15s;
    border-left: 3px solid transparent;
}

.kanban-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card-nr {
    font-size: 11px;
    color: #999;
    font-weight: 500;
    margin-bottom: 2px;
}

.kanban-card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: #1a1a2e;
}

.kanban-card-company {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.kanban-card-company i,
.kanban-card-value i,
.kanban-card-assignee i {
    font-size: 11px;
    margin-right: 3px;
}

.kanban-card-value {
    font-size: 13px;
    font-weight: 600;
    color: #28a745;
    margin-bottom: 4px;
}

.kanban-card-assignee {
    font-size: 12px;
    color: #888;
}

/* Won / Lost cards */
.kanban-card-won {
    border-left-color: #28a745;
    background: #f0faf3;
}

.kanban-card-lost {
    border-left-color: #dc3545;
    background: #fdf0f0;
    opacity: 0.7;
}

/* Won / Lost / Cancelled cards */
.kanban-card-cancelled {
    border-left-color: #6c757d;
    background: #f5f5f5;
    opacity: 0.7;
}

/* Won / Lost / Cancelled columns */
.kanban-column-won {
    background: #e8f5e9;
}

.kanban-column-lost {
    background: #fce4e4;
}

.kanban-column-cancelled {
    background: #ececec;
}

/* Drag & Drop states */
.kanban-ghost {
    opacity: 0.4;
    background: #d0e4ff;
    border-radius: 8px;
}

.kanban-chosen {
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transform: rotate(2deg);
}

.kanban-drag {
    opacity: 0.9;
}

/* Kanban scrollbar */
.kanban-board::-webkit-scrollbar {
    height: 8px;
}

.kanban-board::-webkit-scrollbar-track {
    background: transparent;
}

.kanban-board::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 4px;
}

.kanban-board::-webkit-scrollbar-thumb:hover {
    background: #999;
}
