/* ============================================================
   AlgoCRM — Main Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #a0aec0;
    --sidebar-active: #4f8ef7;
    --sidebar-hover-bg: rgba(79,142,247,0.1);
    --topbar-height: 56px;
    --primary: #4f8ef7;
    --primary-dark: #3a7de0;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --body-bg: #f4f6fc;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.07);
    --radius: 10px;
}

* { box-sizing: border-box; }

body.crm-body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: #2d3748;
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.sidebar-brand i { font-size: 1.4rem; }
/* ALGOTROM logosu koyu kenar çubuğunda beyaz zeminli lockup içinde (renkler korunur) */
.brand-logo {
    display: block;
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    width: 100%;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: transform .15s ease, box-shadow .15s ease;
}
.brand-logo:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.brand-logo img { display: block; width: 100%; max-width: 150px; height: auto; margin: 0 auto; }
.sidebar-tenant { font-size: 0.72rem; color: #718096; text-align: center; }

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

.nav-section {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #4a5568;
    padding: 14px 16px 4px;
    text-transform: uppercase;
}

.nav-item { margin: 1px 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-text) !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: #fff !important;
}

.nav-link.active {
    background: var(--primary);
    color: #fff !important;
    font-weight: 600;
}

.nav-link i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    flex-shrink: 0;
}

.user-details { min-width: 0; }
.user-name { color: #e2e8f0; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8ecf0;
    display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.sidebar-toggle { border: none; background: #f0f2f5; border-radius: 8px; padding: 6px 10px; }
.topbar-breadcrumb { font-size: 0.875rem; color: #718096; }

/* ── PAGE CONTENT ─────────────────────────────────────────── */
.page-content { padding-top: 20px; }

/* ── CARDS ────────────────────────────────────────────────── */
.crm-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid #eef0f5;
}

.crm-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f2f5;
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 0.95rem;
}

.crm-card-body { padding: 20px; }

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid #eef0f5;
    transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }

/* Tıklanabilir KPI kartı (dashboard) */
a.stat-card-link { color: inherit; cursor: pointer; }
a.stat-card-link:hover { transform: translateY(-2px); border-color: #d7dbe6; }
a.stat-card-link .stat-value { color: var(--text, #1f2430); }

/* ── Dashboard grafikler ── */
/* Bar chart (aylık faaliyet) */
.chart-legend { display: flex; gap: 14px; font-size: .75rem; color: #6b7280; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 185px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.bars { display: flex; gap: 5px; align-items: flex-end; min-height: 2px; }
.bar { width: 16px; min-height: 2px; border-radius: 5px 5px 0 0; transition: height .3s; }
.bar-label { font-size: .72rem; color: #6b7280; }

/* Donut (görev durumu) */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ''; position: absolute; inset: 24px; background: #fff; border-radius: 50%; z-index: 1; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; }
.donut-total { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.donut-cap { font-size: .72rem; color: #6b7280; }
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Servis aşama bağlam paneli (önceki aşamalar) */
.ctx-block { padding: 10px 0; border-bottom: 1px dashed #e5e8ef; }
.ctx-block:last-child { border-bottom: 0; }
.ctx-title { font-weight: 600; font-size: .85rem; margin-bottom: 6px; }

/* Pipeline ilerleme çubukları */
.pl-row { padding: 8px 2px; }
.pl-top { display: flex; justify-content: space-between; margin-bottom: 5px; }
.pl-track { height: 8px; background: #eef0f5; border-radius: 6px; overflow: hidden; }
.pl-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #818cf8); border-radius: 6px; }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(79,142,247,0.12); color: #4f8ef7; }
.stat-icon.green  { background: rgba(40,167,69,0.12);  color: #28a745; }
.stat-icon.orange { background: rgba(255,152,0,0.12);  color: #ff9800; }
.stat-icon.purple { background: rgba(156,39,176,0.12); color: #9c27b0; }
.stat-icon.red    { background: rgba(220,53,69,0.12);  color: #dc3545; }
.stat-icon.teal   { background: rgba(0,188,212,0.12);  color: #00bcd4; }

.stat-value { font-size: 1.6rem; font-weight: 700; color: #1a202c; line-height: 1; }
.stat-label { font-size: 0.8rem; color: #718096; margin-top: 2px; }

/* ── TABLES ───────────────────────────────────────────────── */
.crm-table { width: 100%; }
.crm-table thead th {
    background: #f8f9fc;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #718096;
    padding: 12px 16px;
    border-bottom: 2px solid #eef0f5;
    white-space: nowrap;
}
.crm-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f5f7fa;
    font-size: 0.875rem;
    vertical-align: middle;
}
.crm-table tbody tr:hover { background: #fafbfd; }
.crm-table tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge-status {
    font-size: 0.72rem; font-weight: 600;
    padding: 4px 10px; border-radius: 20px;
    display: inline-block; white-space: nowrap;
}
.badge-taslak       { background:#f0f2f5; color:#4a5568; }
.badge-gönderildi   { background:#e3f2fd; color:#1565c0; }
.badge-onaylandı    { background:#e8f5e9; color:#2e7d32; }
.badge-reddedildi   { background:#fce4ec; color:#c62828; }
.badge-iptal        { background:#f5f5f5; color:#757575; }
.badge-tamamlandı   { background:#e8f5e9; color:#2e7d32; }
.badge-beklemede    { background:#fff8e1; color:#f57f17; }
.badge-gerigönderildi { background:#fff7e6; color:#92400e; border:1px solid #fde68a; }
.badge-siparişleşti  { background:#ede9fe; color:#5b21b6; }
.badge-planlandı    { background:#e3f2fd; color:#1565c0; }
.badge-gerçekleşti  { background:#e8f5e9; color:#2e7d32; }
.badge-acil         { background:#fce4ec; color:#c62828; }
.badge-yüksek       { background:#fff3e0; color:#e65100; }
.badge-normal       { background:#e3f2fd; color:#1565c0; }
.badge-düşük        { background:#f5f5f5; color:#616161; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-section {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    border: 1px solid #eef0f5;
    margin-bottom: 20px;
}
.form-section-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f2f5;
    font-weight: 600; font-size: 0.9rem;
    color: #4a5568;
    background: #f8f9fc;
    border-radius: var(--radius) var(--radius) 0 0;
}
.form-section-body { padding: 20px; }

.form-label { font-weight: 600; font-size: 0.82rem; color: #4a5568; margin-bottom: 4px; }
.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    padding: 8px 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,142,247,0.12);
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { font-size: 0.8rem; padding: 5px 12px; }

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #eef0f5;
}
.page-title { font-size: 1.3rem; font-weight: 700; color: #1a202c; margin: 0; }
.page-subtitle { font-size: 0.82rem; color: #718096; margin: 2px 0 0; }

/* ── SEARCH BAR ───────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; border-radius: 8px; }
.search-bar .bi-search {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%); color: #a0aec0;
}

/* ── DETAIL TABS ──────────────────────────────────────────── */
.detail-tabs .nav-link {
    color: #4a5568; padding: 10px 18px;
    font-size: 0.875rem; font-weight: 500;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: none !important;
}
.detail-tabs .nav-link.active {
    color: var(--primary) !important;
    border-bottom: 2px solid var(--primary);
    font-weight: 600;
}

/* ── PIPELINE STAGES ──────────────────────────────────────── */
.stage-badge {
    font-size: 0.72rem; font-weight: 600;
    padding: 4px 10px; border-radius: 20px;
}
.stage-yeni       { background:#e3f2fd; color:#1565c0; }
.stage-nitelikli  { background:#f3e5f5; color:#6a1b9a; }
.stage-teklif     { background:#fff8e1; color:#f57f17; }
.stage-müzakere   { background:#fff3e0; color:#e65100; }
.stage-kazandık   { background:#e8f5e9; color:#1b5e20; }
.stage-kaybettik  { background:#ffebee; color:#b71c1c; }

/* ── KANBAN ───────────────────────────────────────────────── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 20px; }
.kanban-col { min-width: 240px; max-width: 260px; flex-shrink: 0; }
.kanban-col-header {
    padding: 10px 14px; border-radius: 8px 8px 0 0;
    font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.kanban-card {
    background: #fff; border-radius: 8px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    padding: 12px; margin-bottom: 8px;
    border: 1px solid #eef0f5; cursor: pointer;
    transition: box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.12); }

/* ── LINE ITEMS TABLE ─────────────────────────────────────── */
.line-items-table thead th { font-size: 0.75rem; padding: 8px; }
.line-items-table tbody td { padding: 6px 8px; }
.line-items-table .form-control { padding: 5px 8px; font-size: 0.82rem; }

/* ── ACTIVITY FEED ────────────────────────────────────────── */
.activity-item {
    display: flex; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f5f7fa;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 32px; height: 32px; border-radius: 50%;
    background: #e8edf5; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; flex-shrink: 0;
}
.activity-text { font-size: 0.83rem; }
.activity-time { font-size: 0.73rem; color: #a0aec0; }

/* ── PAGINATION ───────────────────────────────────────────── */
.crm-pagination .page-link {
    border: 1.5px solid #e2e8f0; border-radius: 6px !important;
    margin: 0 2px; font-size: 0.82rem; color: #4a5568;
}
.crm-pagination .page-item.active .page-link {
    background: var(--primary); border-color: var(--primary);
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stat-card { padding: 14px; }
}

/* ── PRINT ────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .crm-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── AUTH PAGES ───────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a1f2e 0%, #2d3561 100%);
}
.auth-card {
    background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px; width: 100%; max-width: 420px;
}
.auth-logo { font-size: 2rem; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.auth-logo-img { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto 10px; }
.auth-subtitle { color: #718096; font-size: 0.9rem; margin-bottom: 28px; }

/* ── Aranabilir açılır liste (main.js → aramaliSecim) ── */
.arama-secim { position: relative; }
.arama-secim-asil {                 /* asıl <select>: görünmez ama formda, zorunlu kontrolü çalışır */
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; pointer-events: none; z-index: 0;
}
.arama-secim-kutu { position: relative; z-index: 1; cursor: text; background-color: #fff; }
.arama-secim-liste {
    width: 100%; max-height: 280px; overflow-y: auto; margin-top: 2px; z-index: 1056;
}
.arama-secim-liste .dropdown-item { white-space: normal; font-size: .9rem; }
.arama-secim-liste .arama-secim-vurgu { background: var(--bs-primary-bg-subtle, #e7f1ff); }
