/* =====================================================================
   Mail Delivery System — application styles
   ===================================================================== */
:root {
    --ms-sidebar-w: 260px;
    --ms-bg: #f4f6fb;
    --ms-sidebar-bg: #16213a;
    --ms-sidebar-fg: #b9c2d4;
    --ms-primary: #2563eb;
    --ms-radius: 14px;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--ms-bg);
    color: #23304a;
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------- Auth ------------------------------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #16213a 0%, #1e3a8a 55%, #2563eb 100%);
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 430px; }
.auth-card { border-radius: 18px; overflow: hidden; }
.auth-logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 18px;
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    color: #fff; font-size: 30px;
}

/* ------------------------------ Shell ------------------------------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--ms-sidebar-w);
    background: var(--ms-sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .22s ease;
}
.app-sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(9,15,30,.45); }

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 20px 16px; color: #fff;
}
.brand-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px; font-size: 20px; flex: 0 0 38px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff;
}
.brand-text { font-weight: 700; font-size: 1.02rem; letter-spacing: .2px; }

.sidebar-nav { list-style: none; margin: 0; padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-section {
    font-size: .68rem; text-transform: uppercase; letter-spacing: 1.4px;
    color: #6b7a99; padding: 16px 10px 6px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0;
    border-radius: 10px; color: var(--ms-sidebar-fg);
    text-decoration: none; font-size: .92rem; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.sidebar-link i { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: linear-gradient(90deg, #2563eb, #3b82f6); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(9,15,30,.5);
    opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1040;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.app-main { margin-left: 0; min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; background: rgba(255,255,255,.9);
    backdrop-filter: blur(6px); border-bottom: 1px solid #e6eaf2;
}
.topbar-title { font-weight: 600; color: #33415c; }

.app-content { flex: 1; padding: 22px 20px 40px; width: 100%; max-width: 1400px; margin: 0 auto; }

.app-footer {
    border-top: 1px solid #e6eaf2; background: #fff;
    padding: 10px 22px; font-size: .75rem; color: #97a0b5;
}

@media (min-width: 992px) {
    .app-sidebar { transform: none; }
    .sidebar-backdrop { display: none; }
    .app-main { margin-left: var(--ms-sidebar-w); }
}

/* ------------------------------ Cards ------------------------------- */
.card { border-radius: var(--ms-radius); }
.card-header { border-radius: var(--ms-radius) var(--ms-radius) 0 0 !important; }

.stat-card .card-body { padding: 18px 16px; }
.stat-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 20px;
    margin-bottom: 12px;
}
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: #7b849c; margin-top: 2px; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: #2563eb; color: #fff; font-weight: 700; font-size: .9rem;
}

/* ------------------------------ Editor ------------------------------ */
#toolbar .ql-formats .ql-undo, #toolbar .ql-formats .ql-redo {
    position: relative;
}
.ql-toolbar.ql-snow { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
.ql-container.ql-snow { border-left: 0; border-right: 0; border-bottom: 0; }
.ql-editor { min-height: 240px; font-size: 1rem; }
.ql-editor.ql-blank::before { font-style: normal; color: #a6b0c8; }

/* ---------------------------- DataTables ---------------------------- */
table.dataTable { margin-top: 0 !important; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d9e0ec; border-radius: 8px; padding: .28rem .6rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px; border: 1px solid #e1e6f0 !important; margin-left: 4px;
}
.detail-dl dt { font-weight: 600; }
.detail-dl dd { margin-bottom: .5rem; }

/* ------------------------------ Toasts ------------------------------ */
#toastContainer { z-index: 2000; }

/* ------------------------------ Misc -------------------------------- */
.progress { border-radius: 20px; background: #e7ecf5; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.form-control, .form-select { border-radius: 9px; }
.btn { border-radius: 9px; }
.list-group-item { background: transparent; }
