/* =========================================================
   BTS-CRM - Custom Theme
   Color palette derived from logo: Blue-to-Indigo gradient
   ========================================================= */

:root {
    --primary: #4A5FE0;
    --primary-dark: #3B4CC0;
    --primary-light: #6B7FF5;
    --secondary: #6C63FF;
    --accent: #8B5CF6;
    --sidebar-bg: linear-gradient(180deg, #2D3561 0%, #1B2240 100%);
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --body-bg: #F0F2F8;
    --card-bg: #FFFFFF;
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- RESET & BASE ---- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--body-bg);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary);
}

a:hover {
    color: var(--primary-dark);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ---- APP WRAPPER ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    /* Navigation will handle scroll */
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 16px 8px;
}

.sidebar.collapsed .sidebar-logo {
    width: 36px;
    height: 36px;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-link i {
    margin-right: 0;
    font-size: 18px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.brand-sub {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    white-space: nowrap;
}

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

.sidebar-header {
    color: rgba(255, 255, 255, 0.35);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 18px 20px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(74, 95, 224, 0.35);
    border-left-color: var(--primary-light);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    margin-right: 12px;
    font-size: 15px;
    opacity: 0.85;
}

.sidebar-link.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

/* ---- TOP NAVBAR ---- */
.top-navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1020;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.sidebar.collapsed~.main-content .top-navbar,
.sidebar.collapsed+.top-navbar {
    left: 70px;
}

.sidebar-toggle {
    color: var(--text-muted);
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--body-bg);
    color: var(--primary);
}

.search-box {
    position: relative;
    margin-left: 16px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.search-box input {
    padding: 8px 16px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    width: 280px;
    background: var(--body-bg);
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 95, 224, 0.12);
    outline: none;
}

.nav-profile {
    color: var(--text-dark) !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    flex: 1;
    min-height: 100vh;
    transition: var(--transition);
}

.sidebar.collapsed~.main-content {
    margin-left: 70px;
}

.content-wrapper {
    padding: 24px;
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.page-header .breadcrumb {
    margin: 4px 0 0;
    font-size: 13px;
}

/* ---- CARDS ---- */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    background: var(--card-bg);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-dark);
}

.card-body {
    padding: 20px;
}

/* ---- STAT CARDS ---- */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    backdrop-filter: blur(10px);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    margin: 12px 0 4px;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.85;
    font-weight: 500;
}

.stat-card::after {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    top: -30px;
    right: -30px;
}

.stat-card.bg-gradient-primary {
    background: linear-gradient(135deg, #4A5FE0, #6C63FF);
}

.stat-card.bg-gradient-success {
    background: linear-gradient(135deg, #10B981, #059669);
}

.stat-card.bg-gradient-warning {
    background: linear-gradient(135deg, #F59E0B, #D97706);
}

.stat-card.bg-gradient-danger {
    background: linear-gradient(135deg, #EF4444, #DC2626);
}

.stat-card.bg-gradient-info {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
}

.stat-card.bg-gradient-purple {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
}

/* ---- TABLE STYLES ---- */
.table {
    font-size: 13.5px;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table tbody tr:hover {
    background: rgba(74, 95, 224, 0.04);
}

/* ---- BADGES ---- */
.badge {
    font-weight: 600;
    font-size: 11.5px;
    padding: 5px 10px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

/* ---- STATUS LIGHT COLORS ---- */
.status-light-primary {
    background-color: #E0E7FF !important;
}

/* Light Indigo */
.status-light-success {
    background-color: #DCFCE7 !important;
}

/* Light Green */
.status-light-warning {
    background-color: #FEF9C3 !important;
}

/* Light Yellow */
.status-light-danger {
    background-color: #FEE2E2 !important;
}

/* Light Red */
.status-light-info {
    background-color: #DBEAFE !important;
}

/* Light Blue */
.status-light-secondary {
    background-color: #F1F5F9 !important;
}

/* Light Gray */
.status-light-purple {
    background-color: #F3E8FF !important;
}

/* Light Purple */

/* ---- BUTTONS ---- */
.btn {
    font-weight: 500;
    border-radius: 8px;
    font-size: 13.5px;
    padding: 8px 18px;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 95, 224, 0.35);
}

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

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}

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

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

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

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* ---- FORM STYLES ---- */
.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--border-color);
    font-size: 13.5px;
    padding: 10px 14px;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 95, 224, 0.12);
}

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-dark);
    margin-bottom: 6px;
}

/* ---- MODALS ---- */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 18px 24px;
}

.modal-title {
    font-weight: 700;
    font-size: 18px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
}

/* ---- DATATABLE OVERRIDES ---- */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 4px 8px;
}

.dataTables_wrapper .dataTables_info {
    font-size: 13px;
    color: var(--text-muted);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    margin: 0 2px;
}

/* ---- LOGIN PAGE ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2D3561 0%, #4A5FE0 50%, #6C63FF 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    top: -100px;
    right: -100px;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    bottom: -50px;
    left: -50px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    width: 76px;
    height: 76px;
    border-radius: 16px;
    margin: 0 auto 20px;
    display: block;
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

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

.empty-state h5 {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
}

/* ---- PIPELINE VIEW (Lead statuses) ---- */
.pipeline-card {
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    padding: 14px 16px;
    background: var(--card-bg);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

/* ---- ACTIVITY FEED ---- */
.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 5px;
    flex-shrink: 0;
}

.activity-text {
    font-size: 13px;
    color: var(--text-dark);
}

.activity-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Slightly wider for touch */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .top-navbar {
        left: 0 !important;
        padding: 0 15px;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 1029;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .search-box {
        display: none;
        /* Hide top search on small screens to save space */
    }
}

/* Mobile Table Enhancement - Card View */
@media (max-width: 768px) {
    .table-responsive-stack {
        display: block;
        width: 100%;
    }

    .table-responsive-stack thead {
        display: none;
        /* Hide headers */
    }

    .table-responsive-stack tbody,
    .table-responsive-stack tr,
    .table-responsive-stack td {
        display: block;
        width: 100%;
    }

    .table-responsive-stack tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 10px;
        background: #fff;
        box-shadow: var(--shadow);
    }

    .table-responsive-stack td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #f1f5f9;
        min-height: 40px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .table-responsive-stack td:last-child {
        border-bottom: none;
    }

    .table-responsive-stack td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 700;
        text-align: left;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 10px;
    }

    /* Standard responsive-table fix for those without stack class */
    .table-responsive {
        border-radius: var(--radius);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .content-wrapper {
        padding: 15px;
    }
}

@media (max-width: 576px) {
    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .page-header .btn {
        width: 100%;
        /* Full width buttons on mobile headers */
    }

    .login-card {
        padding: 30px 20px;
        margin: 15px;
    }

    /* Touch Friendly Inputs */
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ---- ANIMATIONS ---- */
.fade-in {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ---- MISC ---- */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-lift {
    transition: var(--transition);
}

.hover-lift:hover {
    transform: translateY(-2px);
}

.border-left-primary {
    border-left: 4px solid var(--primary) !important;
}

.border-left-success {
    border-left: 4px solid var(--success) !important;
}

.border-left-warning {
    border-left: 4px solid var(--warning) !important;
}

.border-left-danger {
    border-left: 4px solid var(--danger) !important;
}

/* ---- KANBAN BOARD ---- */
.kanban-board {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    padding: 0.5rem 0 1.5rem 0;
    min-height: calc(100vh - 250px);
}

.kanban-column {
    flex: 0 0 300px;
    background: #f8fafc;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.kanban-header {
    padding: 1rem;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0, 0, 0, 0.03);
}

.kanban-tasks {
    padding: 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.kanban-card {
    background: #fff;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid #edf2f7;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: grab;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.kanban-card .priority-indicator {
    width: 30px;
    height: 4px;
    border-radius: 2px;
    margin-bottom: 0.75rem;
}

.kanban-card h6 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.kanban-card .card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #718096;
}

.kanban-card .task-project {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.nav-pills-custom .nav-link {
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    color: #718096;
    transition: all 0.2s;
}

.nav-pills-custom .nav-link.active {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 95, 224, 0.25);
}