/* ============================================================
   MailPulse — Custom Styles
   Premium SaaS Admin Dashboard
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #6366f1;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 4px 24px rgba(0,0,0,.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.1);
    --transition: all .2s ease;
    --font: 'Inter', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 28px;
    color: var(--primary-light);
    filter: drop-shadow(0 0 8px rgba(99,102,241,.4));
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.5px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

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

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

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

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-user:hover {
    background: var(--sidebar-hover);
}

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

.user-name {
    display: block;
    color: #e2e8f0;
    font-weight: 600;
    font-size: 13px;
}

.user-role {
    display: block;
    color: var(--sidebar-text);
    font-size: 11px;
}

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

.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

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

.content-wrapper {
    padding: 24px;
}

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

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

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

.card-body { padding: 20px; }

/* ---- Stat cards ---- */
.stat-card {
    position: relative;
    overflow: hidden;
    border: none;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 4px;
}

.stat-card .stat-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    right: -30px;
    top: -30px;
    opacity: .12;
}

.stat-primary { background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%); color: #fff; }
.stat-primary .stat-label { color: rgba(255,255,255,.75); }
.stat-primary .stat-glow { background: #fff; }

.stat-success { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: #fff; }
.stat-success .stat-label { color: rgba(255,255,255,.75); }
.stat-success .stat-glow { background: #fff; }

.stat-warning { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); color: #fff; }
.stat-warning .stat-label { color: rgba(255,255,255,.75); }
.stat-warning .stat-glow { background: #fff; }

.stat-danger { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); color: #fff; }
.stat-danger .stat-label { color: rgba(255,255,255,.75); }
.stat-danger .stat-glow { background: #fff; }

.stat-info { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); color: #fff; }
.stat-info .stat-label { color: rgba(255,255,255,.75); }
.stat-info .stat-glow { background: #fff; }

.stat-dark { background: linear-gradient(135deg, #334155 0%, #475569 100%); color: #fff; }
.stat-dark .stat-label { color: rgba(255,255,255,.75); }
.stat-dark .stat-glow { background: #fff; }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
}

.progress-bar {
    border-radius: 4px;
    transition: width .6s ease;
}

.progress-animated .progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--primary));
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    font-size: 13.5px;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
}

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

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

.table tbody tr:hover {
    background: var(--primary-bg);
}

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

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

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99,102,241,.3);
    transform: translateY(-1px);
}

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

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

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

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 9px 14px;
    font-size: 13.5px;
    transition: var(--transition);
}

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

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

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--radius);
    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 {
    border-radius: var(--radius-sm);
    border: none;
    box-shadow: var(--shadow-lg);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,.2) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16,185,129,.15) 0%, transparent 70%);
    bottom: -80px;
    left: -80px;
    border-radius: 50%;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,.03);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
    padding: 40px 36px;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-card .brand-icon {
    font-size: 40px;
}

.login-card h2 {
    color: #fff;
    font-weight: 700;
    font-size: 24px;
}

.login-card p {
    color: var(--sidebar-text);
    font-size: 14px;
}

.login-card .form-control {
    background: rgba(255,255,255,.05);
    border: 1.5px solid rgba(255,255,255,.1);
    color: #fff;
    padding: 12px 16px;
}

.login-card .form-control::placeholder {
    color: rgba(255,255,255,.35);
}

.login-card .form-control:focus {
    background: rgba(255,255,255,.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}

.login-card .form-label {
    color: var(--sidebar-text);
}

.login-card .btn-primary {
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
}

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

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

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

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

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-loader {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(.8); opacity: .5; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 16px;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
}

/* ============================================================
   DATATABLE OVERRIDES
   ============================================================ */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
}

/* ============================================================
   CAMPAIGN DETAIL
   ============================================================ */
.campaign-progress-ring {
    width: 120px;
    height: 120px;
    position: relative;
}

.campaign-progress-ring svg {
    transform: rotate(-90deg);
}

.campaign-progress-ring .progress-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

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

.fade-in-up {
    animation: fadeInUp .4s ease-out;
}

.card { animation: fadeInUp .4s ease-out both; }
.card:nth-child(1) { animation-delay: .05s; }
.card:nth-child(2) { animation-delay: .1s; }
.card:nth-child(3) { animation-delay: .15s; }
.card:nth-child(4) { animation-delay: .2s; }
.card:nth-child(5) { animation-delay: .25s; }
.card:nth-child(6) { animation-delay: .3s; }
