@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-sidebar: #111827; /* Dark elegant sidebar */
    --text-sidebar: #9ca3af;
    --text-sidebar-active: #ffffff;
    
    --primary: #4f46e5; /* Indigo/Purple vibe */
    --primary-hover: #4338ca;
    --secondary: #10b981; /* Emerald green */
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    
    --border-light: #e5e7eb;
    
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    
    --radius: 8px;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

body { background: var(--bg-body); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; }

/* =========================================
   SIDEBAR (Dark Premium)
========================================= */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo span { color: var(--primary); }

.nav-section { margin-top: 20px; }
.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 20px;
    margin-bottom: 10px;
    color: #6b7280;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-item .icon { margin-right: 12px; font-size: 1.1rem; opacity: 0.8; }
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.05);
    color: var(--text-sidebar-active);
    border-left-color: var(--primary);
}
.nav-item:hover .icon, .nav-item.active .icon { opacity: 1; }

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

/* =========================================
   MAIN LAYOUT & TOPBAR
========================================= */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 64px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 15px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.page-title { font-size: 1.2rem; font-weight: 600; color: var(--text-main); }
.header-btn {
    background: none; border: none; cursor: pointer; font-size: 1.2rem;
    color: var(--text-muted); transition: var(--transition);
}
.header-btn:hover { color: var(--primary); }

.user-profile-btn {
    display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; font-weight: 500;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.9rem;
}

.page-body {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
}

/* =========================================
   UI COMPONENTS
========================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-title { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 20px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border-radius: 6px; font-weight: 500; font-size: 0.9rem;
    cursor: pointer; border: 1px solid transparent; transition: var(--transition);
    text-decoration: none; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border-color: var(--border-light); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--secondary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 6px; border-radius: 4px; }

/* =========================================
   FORMS & INPUTS
========================================= */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.form-control {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-light);
    border-radius: 6px; font-size: 0.9rem; transition: var(--transition);
    background: #f9fafb;
}
.form-control:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

/* =========================================
   TABLES
========================================= */
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 12px 20px; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.data-table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
.data-table tbody tr:hover { background: #f9fafb; }

.badge {
    padding: 4px 8px; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #e5e7eb; color: #374151; }

/* =========================================
   KANBAN BOARD (CRM PIPELINE)
========================================= */
.kanban-board {
    display: flex; gap: 20px; overflow-x: auto; padding-bottom: 20px; height: calc(100vh - 160px);
}
.kanban-column {
    flex: 0 0 300px;
    background: #f4f5f7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}
.kanban-column-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-light);
}
.kanban-column-body {
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
}
.kanban-card {
    background: #fff;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    cursor: grab;
    transition: var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; transform: translateY(-2px); }
.kanban-card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; color: var(--primary); }
.kanban-card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--text-muted); border-top: 1px dashed var(--border-light); padding-top: 8px; }

/* =========================================
   MODALS & OFF-CANVAS
========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center; z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-card); width: 100%; max-width: 500px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); overflow: hidden; animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; background: #f9fafb; }

/* Off-Canvas Right Panel (For Lead Details) */
.offcanvas-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3);
    z-index: 900; display: none;
}
.offcanvas {
    position: fixed; top: 0; right: -500px; width: 500px; height: 100vh;
    background: #fff; box-shadow: -5px 0 15px rgba(0,0,0,0.1); z-index: 950;
    transition: right 0.3s ease; display: flex; flex-direction: column;
}
.offcanvas.open { right: 0; }
.offcanvas-header { padding: 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; background: #f9fafb; }
.offcanvas-body { padding: 20px; overflow-y: auto; flex-grow: 1; }

/* Timeline (Activities) */
.timeline { border-left: 2px solid var(--border-light); margin-left: 10px; padding-left: 20px; position: relative; }
.timeline-item { margin-bottom: 20px; position: relative; }
.timeline-icon {
    position: absolute; left: -31px; top: 0; width: 20px; height: 20px; border-radius: 50%;
    background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.6rem;
}
.timeline-content { background: #f9fafb; padding: 12px; border-radius: 6px; border: 1px solid var(--border-light); }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Stat Cards */
.stat-card {
    background: #fff; border-radius: var(--radius); padding: 20px;
    border: 1px solid var(--border-light); display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.stat-icon.blue { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: #ecfdf5; color: #10b981; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.orange { background: #fff7ed; color: #f97316; }
.stat-details { flex-grow: 1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.w-100 { width: 100%; }

/* =========================================
   RESPONSIVE — Mobile First
========================================= */

/* Tablet & Mobile ortak */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {

    /* ---- Body & Layout ---- */
    body { overflow: hidden; position: relative; }

    .app-layout {
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }

    /* ---- Sidebar ---- */
    .sidebar,
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
        overflow-y: auto;
    }
    .sidebar.open,
    #sidebar.open {
        transform: translateX(0);
    }

    /* Sidebar overlay (blur backdrop) */
    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        backdrop-filter: blur(2px);
        z-index: 999;
    }
    #sidebarOverlay.show { display: block; }

    /* ---- Main content ---- */
    .main-content {
        width: 100%;
        height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- Header ---- */
    .app-header {
        padding: 0 14px;
        height: 54px;
        min-height: 54px;
        position: sticky;
        top: 0;
        z-index: 100;
        background: #fff;
        border-bottom: 1px solid var(--border-light);
    }
    .app-header h1 {
        font-size: 1rem;
    }

    /* Hamburger menu button */
    #menuToggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: transparent;
        cursor: pointer;
        font-size: 1.35rem;
        color: var(--text-main);
        margin-right: 10px;
        border-radius: 6px;
        transition: background .2s;
    }
    #menuToggle:hover { background: var(--border-light); }

    /* ---- Page Content ---- */
    .page-content {
        padding: 14px;
    }

    /* ---- Grids ---- */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* ---- Stat Grid ---- */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    .stat-card {
        padding: 14px;
        gap: 10px;
    }
    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
    .stat-value { font-size: 1.2rem; }
    .stat-label { font-size: .75rem; }

    /* ---- Cards ---- */
    .card { margin-bottom: 14px; }
    .card-header { padding: 12px 14px; }
    .card-body { padding: 14px; }

    /* ---- Tables — horizontal scroll ---- */
    .card .data-table,
    [style*="overflow-x:auto"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { font-size: .8rem; min-width: 500px; }
    .data-table th, .data-table td { padding: 8px 10px; }

    /* ---- Buttons ---- */
    .btn { min-height: 38px; }
    .btn-sm { min-height: 32px; font-size: .78rem; }
    .btn-full { width: 100%; }

    /* ---- Forms ---- */
    .form-control { font-size: 16px; /* iOS zoom önlemi */ }
    .form-select { font-size: 16px; }

    /* ---- Modals ---- */
    .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90dvh;
        overflow-y: auto;
        animation: slideUp .25s ease;
    }
    @keyframes slideUp {
        from { transform: translateY(60px); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 12px 14px; }

    /* ---- Kanban ---- */
    .kanban-board {
        flex-direction: column;
        height: auto;
        gap: 14px;
        padding-bottom: 80px;
    }
    .kanban-column {
        flex: none;
        width: 100%;
        max-height: 400px;
    }
    .kanban-column-body { max-height: 340px; }

    /* ---- Flex between ---- */
    .flex-between { flex-wrap: wrap; gap: 8px; }
    .flex-between > * { flex: 1 1 auto; }

    /* ---- Notification panel ---- */
    #notifPanel {
        position: fixed !important;
        top: 54px !important;
        right: 0 !important;
        width: 100% !important;
        border-radius: 0 !important;
    }

    /* ---- Alert ---- */
    .alert { font-size: .85rem; padding: 10px 14px; }

    /* ---- Pipeline ---- */
    .kanban-card { touch-action: none; }

    /* ---- Lead detail (360) ---- */
    .timeline { margin-left: 4px; padding-left: 14px; }

    /* ---- Supervisor panel ---- */
    #agentBoard > div { flex-wrap: wrap; }

    /* ---- Call popup ---- */
    .call-popup {
        width: calc(100vw - 28px) !important;
        max-width: 100% !important;
        left: 14px !important;
        right: 14px !important;
        bottom: 14px !important;
        top: auto !important;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .stat-grid { grid-template-columns: 1fr !important; }
    .stat-card { flex-direction: row; }
}
