/* ============================================================
   BulkMailer Pro - Main Stylesheet
   ============================================================ */

:root {
    --primary:      #4f46e5;
    --primary-dark: #3730a3;
    --primary-light:#eef2ff;
    --secondary:    #64748b;
    --success:      #10b981;
    --danger:       #ef4444;
    --warning:      #f59e0b;
    --info:         #3b82f6;
    --dark:         #0f172a;
    --surface:      #ffffff;
    --bg:           #f8fafc;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --text-muted:   #64748b;
    --sidebar-w:    260px;
    --header-h:     60px;
    --radius:       10px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.07);
    --shadow:       0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.12);
    --transition:   all .2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.6; }

/* ---- Typography ---- */
h1,h2,h3,h4,h5,h6 { font-weight: 600; color: var(--dark); margin-bottom: .5rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
}
.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.75rem;
}
.auth-logo i { font-size: 1.6rem; }
.auth-title { font-size: 1.25rem; font-weight: 600; color: var(--dark); margin-bottom: .25rem; }
.auth-subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.75rem; }

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

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform .3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    min-height: var(--header-h);
}
.sidebar-brand i { color: #818cf8; font-size: 1.3rem; }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section-title {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #475569;
    padding: .75rem 1.5rem .25rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    color: #94a3b8;
    font-size: .875rem;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}
.sidebar-link i { font-size: 1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-link.active { color: #fff; background: rgba(79,70,229,.35); }
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #818cf8;
    border-radius: 0 2px 2px 0;
}
.sidebar-link .badge { margin-left: auto; }
.sidebar-submenu { display: none; background: rgba(0,0,0,.2); }
.sidebar-submenu .sidebar-link { padding-left: 3rem; font-size: .825rem; }
.sidebar-item.open .sidebar-submenu { display: block; }
.sidebar-toggle-icon { margin-left: auto; transition: transform .2s; }
.sidebar-item.open .sidebar-toggle-icon { transform: rotate(180deg); }

.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: .875rem;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #fff; font-weight: 600; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: #475569; font-size: .7rem; }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: var(--shadow-sm);
}
.topbar-toggle { display: none; background: none; border: none; color: var(--secondary); font-size: 1.25rem; cursor: pointer; padding: .25rem; }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--dark); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-user { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .25rem .5rem; border-radius: 8px; }
.topbar-user:hover { background: var(--bg); }
.topbar-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: .8rem;
}

/* ---- Page Body ---- */
.page-body { padding: 1.5rem; flex: 1; }
.page-header { margin-bottom: 1.5rem; }
.page-header-title { font-size: 1.25rem; font-weight: 700; color: var(--dark); margin: 0; }
.page-header-subtitle { color: var(--text-muted); font-size: .875rem; margin: .25rem 0 0; }
.breadcrumb { font-size: .8rem; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card-title { font-size: .95rem; font-weight: 600; color: var(--dark); margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg); }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex-shrink: 0;
}
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-icon.danger  { background: #fee2e2; color: var(--danger); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.info    { background: #dbeafe; color: var(--info); }
.stat-icon.purple  { background: #ede9fe; color: #7c3aed; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }
.stat-change { font-size: .75rem; margin-top: .35rem; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.table { margin: 0; }
.table thead th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
    white-space: nowrap;
}
.table tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f8fafc; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 500; font-size: .875rem; color: var(--text); margin-bottom: .4rem; }
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .875rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    outline: none;
}
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: .8rem; color: var(--danger); }
.form-text { font-size: .78rem; color: var(--text-muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { font-size: .875rem; font-weight: 500; border-radius: 8px; padding: .45rem .9rem; transition: var(--transition); border: 1px solid transparent; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .35rem .5rem; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-size: .7rem; font-weight: 600; padding: .28em .6em; border-radius: 6px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-content { border: none; border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 1.15rem 1.5rem; }
.modal-title { font-size: 1rem; font-weight: 600; color: var(--dark); }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1rem 1.5rem; }

/* ============================================================
   PROGRESS
   ============================================================ */
.progress { border-radius: 100px; background: var(--border); }
.progress-bar { border-radius: 100px; transition: width .5s ease; }

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */
.search-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .3rem .75rem;
}
.search-bar i { color: var(--text-muted); }
.search-bar input { border: none; outline: none; background: transparent; font-size: .875rem; color: var(--text); min-width: 180px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .3; }
.empty-state h5 { color: var(--dark); font-size: 1rem; margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; }

/* ============================================================
   LOADING INDICATOR
   ============================================================ */
.spinner-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; display: none;
}
.spinner-overlay.show { display: flex; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary { color: var(--primary) !important; }
.text-muted   { color: var(--text-muted) !important; }
.fw-600 { font-weight: 600; }
.gap-2 { gap: .5rem; }
.rounded-pill-sm { border-radius: 50px; }
.cursor-pointer { cursor: pointer; }
.hover-lift { transition: var(--transition); }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.divider { border-top: 1px solid var(--border); margin: 1rem 0; }
.section-divider { border-top: 1px dashed var(--border); margin: 1.5rem 0; }

/* ============================================================
   CHARTS AREA
   ============================================================ */
.chart-container { position: relative; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: none; }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .main-content { margin-left: 0; }
    .topbar-toggle { display: block; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.25rem; }
}
@media (max-width: 575.98px) {
    .page-body { padding: 1rem; }
    .auth-card { padding: 2rem 1.25rem; }
}

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .25s ease both; }

/* ---- Print ---- */
@media print {
    .sidebar, .topbar, .btn, .pagination { display: none !important; }
    .main-content { margin-left: 0 !important; }
}

/* ============================================================
   CUSTOM CONFIRM POPUP
   ============================================================ */
#bcpOverlay {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .22s ease;
}
#bcpOverlay.bcp-show { opacity: 1; }

.bcp-backdrop {
    position: absolute; inset: 0;
    background: rgba(15,10,40,.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bcp-box {
    position: relative; z-index: 1;
    background: #fff;
    border-radius: 20px;
    padding: 2rem 2rem 1.6rem;
    width: 100%; max-width: 360px;
    margin: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.1), 0 32px 64px rgba(0,0,0,.15);
    text-align: center;
    transform: translateY(24px) scale(.96);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
    opacity: 0;
}
#bcpOverlay.bcp-show .bcp-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.bcp-icon-wrap {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.1rem;
}
.bcp-icon-wrap i { font-size: 1.75rem; }

.bcp-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #21201c;
    margin-bottom: .45rem;
}

.bcp-msg {
    font-size: .85rem;
    color: #6f6b63;
    line-height: 1.55;
    margin-bottom: 1.6rem;
}

.bcp-actions {
    display: flex; gap: .65rem;
}

.bcp-btn {
    flex: 1;
    padding: .6rem 1rem;
    border: none; border-radius: 11px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: .845rem; font-weight: 600;
    cursor: pointer;
    transition: all .18s ease;
}

.bcp-btn-cancel {
    background: #f0ede8; color: #6f6b63;
}
.bcp-btn-cancel:hover { background: #e5e1db; color: #21201c; }

.bcp-btn-danger  { background: #c0504d; color: #fff; }
.bcp-btn-danger:hover  { background: #a64442; transform: translateY(-1px); }

.bcp-btn-warning { background: #b07d28; color: #fff; }
.bcp-btn-warning:hover { background: #946820; transform: translateY(-1px); }

.bcp-btn-success { background: #2e8f63; color: #fff; }
.bcp-btn-success:hover { background: #247a54; transform: translateY(-1px); }

.bcp-btn-primary { background: #4f46e5; color: #fff; }
.bcp-btn-primary:hover { background: #3d35a0; transform: translateY(-1px); }

/* ============================================================
   QUILL EDITOR OVERRIDES
   ============================================================ */
.ql-container { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.ql-toolbar { border-top-left-radius: 8px; border-top-right-radius: 8px; background: var(--bg); }
.ql-editor { min-height: 250px; font-family: inherit; font-size: .875rem; }

/* ============================================================
   QUEUE / PROGRESS STATUS
   ============================================================ */
.queue-progress { background: #f1f5f9; border-radius: var(--radius); padding: 1.25rem; }
.queue-stat { text-align: center; }
.queue-stat-val { font-size: 1.5rem; font-weight: 700; }
.queue-stat-label { font-size: .75rem; color: var(--text-muted); }

/* ============================================================
   VALIDATION STATUS INDICATOR
   ============================================================ */
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; margin-right: .35rem;
}
.status-dot.valid     { background: var(--success); }
.status-dot.invalid   { background: var(--danger); }
.status-dot.risky     { background: var(--warning); }
.status-dot.unknown   { background: var(--secondary); }
