/* ============================================================
   eSMS Admin — Stylesheet
   ============================================================ */

:root {
    --primary:      #4F46E5;
    --primary-dark: #3730A3;
    --primary-light:#EEF2FF;
    --success:      #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --info:         #3B82F6;
    --purple:       #8B5CF6;

    --bg:           #F1F5F9;
    --bg-card:      #FFFFFF;
    --sidebar-bg:   #1E1B4B;
    --sidebar-text: #C7D2FE;
    --sidebar-hover:#312E81;
    --sidebar-active:#4F46E5;

    --text-primary: #1E293B;
    --text-secondary:#64748B;
    --text-light:   #94A3B8;
    --border:       #E2E8F0;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

    --sidebar-w:    250px;
    --topbar-h:     64px;
    --transition:   .22s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
       background: var(--bg); color: var(--text-primary);
       display: flex; min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,.15);
}

.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer .balance-card div { display: none; }
.sidebar.collapsed .logo { justify-content: center; }

.sidebar-header {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}
.logo i { font-size: 1.4rem; color: #818CF8; }

.toggle-btn {
    background: none; border: none; cursor: pointer;
    color: var(--sidebar-text); font-size: 1rem; padding: 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.toggle-btn:hover { background: rgba(255,255,255,.1); }

/* Nav items */
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .9rem;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-item i { font-size: 1.05rem; min-width: 20px; text-align: center; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

/* Sidebar footer balance */
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.balance-card {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,.08);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: #fff;
}
.balance-card i { font-size: 1.2rem; color: #34D399; }
.balance-card small { display: block; font-size: .72rem; color: var(--sidebar-text); }
.balance-card strong { font-size: .95rem; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-content { margin-left: 68px; }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.menu-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: var(--text-secondary);
    padding: 6px; border-radius: var(--radius-sm);
}
.page-title { font-size: 1.15rem; font-weight: 600; }

.user-badge {
    display: flex; align-items: center; gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: .85rem; font-weight: 600;
}

/* ============================================================
   PAGES
   ============================================================ */
.page { display: none; padding: 24px; animation: fadeIn .2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
}
.stat-card.blue   { border-color: var(--info); }
.stat-card.green  { border-color: var(--success); }
.stat-card.orange { border-color: var(--warning); }
.stat-card.purple { border-color: var(--purple); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.blue   .stat-icon { background: #EFF6FF; color: var(--info); }
.green  .stat-icon { background: #ECFDF5; color: var(--success); }
.orange .stat-icon { background: #FFFBEB; color: var(--warning); }
.purple .stat-icon { background: #F5F3FF; color: var(--purple); }

.stat-label { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: 2px; }
.stat-value { display: block; font-size: 1.4rem; font-weight: 700; }

/* ── Dashboard Grid ── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
    font-size: .95rem;
}
.card-header i { color: var(--primary); }
.card-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.mb-16 { margin-bottom: 16px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: .88rem; color: var(--text-secondary); }
.form-group.inline { display: inline-flex; align-items: center; gap: 8px; margin-right: 12px; }
.form-group.inline label { margin-bottom: 0; white-space: nowrap; }

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-input-sm { width: auto; padding: 6px 10px; font-size: .85rem; }

.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

.required { color: var(--danger); }
.hint { font-size: .78rem; color: var(--text-light); margin-top: 3px; display: block; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-weight: 500; font-size: .88rem;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #CBD5E1; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: none; color: var(--text-secondary); font-size: .8rem; padding: 4px 8px; margin-left: auto; }
.btn-ghost:hover { background: var(--border); }
.btn-refresh { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1rem; padding: 6px; border-radius: var(--radius-sm); }
.btn-refresh:hover { background: var(--border); color: var(--primary); }
.btn-full { width: 100%; justify-content: center; padding: 10px; font-size: .95rem; }
.btn-xs   { font-size: .75rem; padding: 3px 8px; }

/* ============================================================
   SMS PREVIEW / PHONE MOCKUP
   ============================================================ */
.sms-preview {
    background: #F8FAFC;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}
.sms-preview em { color: var(--primary); font-style: normal; }
.sms-counter { text-align: right; font-size: .78rem; color: var(--text-light); margin-top: 4px; }
.sms-part { margin-left: 8px; color: var(--primary); font-weight: 600; }

.phone-mockup {
    max-width: 280px; margin: 0 auto;
    background: #1a1a2e;
    border-radius: 28px;
    padding: 24px 12px 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,.2), inset 0 0 0 2px #333;
}
.phone-screen {
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    min-height: 150px;
}
.phone-sms-header {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: .9rem; margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
}
.phone-sms-body {
    font-size: .88rem; color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.phone-sms-time { text-align: right; font-size: .72rem; color: var(--text-light); margin-top: 10px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: .88rem;
}
.data-table th {
    background: #F8FAFC;
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #F8FAFC; }
.table-empty { text-align: center; color: var(--text-light); padding: 40px !important; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 12px;
    font-size: .75rem; font-weight: 600;
}
.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-gray    { background: #F1F5F9; color: #64748B; }

/* ============================================================
   RESULT BOXES
   ============================================================ */
.result-box {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: .88rem;
    line-height: 1.7;
}
.result-box.success { background: #ECFDF5; border: 1px solid #A7F3D0; color: #065F46; }
.result-box.error   { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.result-box.info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.result-box strong  { display: block; margin-bottom: 6px; font-size: .95rem; }
.result-box .smsid  { font-family: monospace; font-size: .82rem; word-break: break-all;
                      background: rgba(0,0,0,.05); padding: 4px 6px; border-radius: 4px; }

/* ============================================================
   LOG
   ============================================================ */
.log-container {
    background: #0F172A;
    border-radius: var(--radius-sm);
    padding: 12px;
    height: 240px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: .8rem;
}
.log-empty { color: #475569; text-align: center; margin-top: 80px; }
.log-line { padding: 2px 0; line-height: 1.5; }
.log-time { color: #475569; }
.log-ok   { color: #34D399; }
.log-err  { color: #F87171; }
.log-info { color: #60A5FA; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end;
    gap: 8px; margin-bottom: 16px;
    padding: 14px;
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.filter-bar .form-group { margin-bottom: 0; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex; gap: 6px; justify-content: center;
    margin-top: 16px;
}
.pagination .btn { padding: 6px 10px; min-width: 36px; justify-content: center; }

/* ============================================================
   PAGE GRIDS
   ============================================================ */
.page-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1E293B; color: #fff;
    padding: 12px 20px; border-radius: var(--radius);
    font-size: .88rem; font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0; transform: translateY(10px);
    transition: all .25s ease;
    max-width: 320px;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1a1a1a; }

/* ============================================================
   LOADING
   ============================================================ */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(2px);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MISC
   ============================================================ */
.mt-16 { margin-top: 16px; }
.copy-btn { background: none; border: none; cursor: pointer; color: var(--primary); font-size: .8rem; padding: 2px 6px; }
.copy-btn:hover { text-decoration: underline; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-grid-2    { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .menu-btn { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; }
}
