/* =============================================
   CRM System — Master Stylesheet
   Dark Mode UI with Indigo/Violet Accent
   ============================================= */

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

/* ---------- CSS Variables ---------- */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;

    --bg-body: #0f1117;
    --bg-sidebar: #13151c;
    --bg-card: #1a1d27;
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.07);

    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: var(--primary);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
    margin: 0;
}

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

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

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

/* =============================================
   SIDEBAR 
   ============================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-brand:hover {
    color: var(--text-primary);
}

.sidebar-brand .brand-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand .brand-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-close {
    color: var(--text-muted);
    border: none;
    padding: 0;
    line-height: 1;
}

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

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 12px 20px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    margin: 1px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

.nav-item i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    opacity: 0.7;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.nav-item:hover i {
    opacity: 1;
}

.nav-item.active {
    color: #fff;
    background: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-item.active i {
    opacity: 1;
    color: var(--primary);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

/* =============================================
   MAIN CONTENT 
   ============================================= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Top Navbar ---------- */
.top-navbar {
    height: var(--topbar-height);
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.top-navbar .page-title h4 {
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    color: var(--text-secondary);
    border: none;
    padding: 4px;
    display: none;
}

.notification-bell {
    color: var(--text-secondary);
    font-size: 20px;
    padding: 6px;
    border: none;
    background: none;
    position: relative;
}

.notification-bell:hover {
    color: var(--text-primary);
}

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

/* ---------- Page Content ---------- */
.page-content {
    flex: 1;
    padding: 24px;
}

/* =============================================
   CARDS 
   ============================================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

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

.card-header h5,
.card-header h6 {
    margin: 0;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ---------- KPI Stat Cards ---------- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.15);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.05;
    transform: translate(30%, -30%);
}

.stat-card.stat-primary::after {
    background: var(--primary);
}

.stat-card.stat-success::after {
    background: var(--success);
}

.stat-card.stat-warning::after {
    background: var(--warning);
}

.stat-card.stat-danger::after {
    background: var(--danger);
}

.stat-card.stat-info::after {
    background: var(--info);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.stat-primary .stat-icon {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-success .stat-icon {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.stat-warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-danger .stat-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.stat-info .stat-icon {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

/* =============================================
   FORMS 
   ============================================= */
.form-control,
.form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 13px;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

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

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.input-group-text {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* =============================================
   BUTTONS 
   ============================================= */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    letter-spacing: 0.3px;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, var(--primary-hover), var(--accent-hover));
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

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

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

/* =============================================
   TABLES 
   ============================================= */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table thead th {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
    font-size: 13px;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

.badge-draft {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

.badge-scheduled {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.badge-running,
.badge-sending {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.badge-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-paused {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-sent {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-opened {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.badge-bounced {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* =============================================
   MODALS 
   ============================================= */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

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

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

/* =============================================
   TOAST 
   ============================================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    min-width: 320px;
}

.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
}

/* =============================================
   DROPDOWN 
   ============================================= */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 200px;
}

.dropdown-item {
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.dropdown-item i {
    width: 20px;
    margin-right: 8px;
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* =============================================
   NOTIFICATION DROPDOWN 
   ============================================= */
.notification-dropdown {
    width: 350px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: var(--transition);
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.05);
}

/* =============================================
   DATATABLES OVERRIDES 
   ============================================= */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--border-color) !important;
    background: transparent !important;
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    padding: 6px 12px !important;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-light) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
}

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

/* =============================================
   LOGIN PAGE 
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
}

.login-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-body);
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    position: relative;
    overflow: hidden;
}

.login-right::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent);
    top: 20%;
    right: 10%;
    border-radius: 50%;
}

@media (max-width: 767.98px) {
    .login-wrapper {
        flex-direction: column;
    }

    .login-right {
        display: none;
    }

    .login-left {
        padding: 20px;
    }
}

/* ---------- Content Card ---------- */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- Quick Action Buttons ---------- */
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

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

.quick-action-btn i {
    font-size: 18px;
    color: var(--primary);
}

/* ---------- Tags ---------- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    margin: 1px;
}

/* ---------- Animations ---------- */
.fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* ---------- Chart Container ---------- */
.chart-container {
    position: relative;
    min-height: 250px;
}

/* ---------- Progress Bars ---------- */
.progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ---------- Form Check ---------- */
.form-check-input {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ---------- Activity Text ---------- */
.activity-text {
    font-size: 13px;
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* ---------- Countdown ---------- */
.countdown {
    display: inline-flex;
    gap: 4px;
}

.countdown-unit {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(26, 29, 39, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    padding: 40px;
}

.login-card .brand-icon {
    font-size: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card .btn-login {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius);
    font-weight: 600;
    letter-spacing: 0.5px;
    width: 100%;
    font-size: 15px;
    color: #fff;
    transition: var(--transition);
}

.login-card .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

/* =============================================
   EMPTY STATE 
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h5 {
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 13px;
}

/* =============================================
   ACTIVITY FEED 
   ============================================= */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

/* =============================================
   LOADING SPINNER 
   ============================================= */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* =============================================
   CHART CARDS 
   ============================================= */
.chart-card canvas {
    max-height: 300px;
}

/* =============================================
   ANIMATIONS 
   ============================================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

.stagger>* {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}

.stagger> :nth-child(1) {
    animation-delay: 0.05s;
}

.stagger> :nth-child(2) {
    animation-delay: 0.1s;
}

.stagger> :nth-child(3) {
    animation-delay: 0.15s;
}

.stagger> :nth-child(4) {
    animation-delay: 0.2s;
}

.stagger> :nth-child(5) {
    animation-delay: 0.25s;
}

.stagger> :nth-child(6) {
    animation-delay: 0.3s;
}

.stagger> :nth-child(7) {
    animation-delay: 0.35s;
}

.stagger> :nth-child(8) {
    animation-delay: 0.4s;
}

/* =============================================
   RESPONSIVE 
   ============================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .sidebar-toggle {
        display: flex !important;
    }

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