:root {
    --primary: #0e9f6e;
    --primary-dark: #057a55;
    --primary-light: #d1fae5;
    --secondary: #f59e0b;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #e2e8f0;
    --light: #f8fafc;
    --ink: #0f172a;
    --body: #475569;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.08);
    --shadow-md: 0 4px 16px rgba(15,23,42,0.08);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f1f5f9;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ---------------------------------------------------------
   LOGIN PAGE
   --------------------------------------------------------- */
.login-page {
    background:
        radial-gradient(circle at 20% 20%, rgba(16,185,129,0.3) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(245,158,11,0.2) 0%, transparent 40%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-box {
    background: #fff;
    border-radius: 20px;
    padding: 44px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    font-size: 1.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(14,159,110,0.3);
}

.login-header h1 {
    color: var(--ink);
    font-size: 1.7rem;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.login-header p { color: var(--body); font-size: 0.92rem; }

/* ---------------------------------------------------------
   BUTTONS
   --------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    background: #e2e8f0;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(14,159,110,0.25);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-block { width: 100%; padding: 15px; font-size: 1rem; }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; border-radius: 8px; }

.btn-edit { background: #eff6ff; color: #2563eb; }
.btn-toggle { background: #f0fdf4; color: var(--success); }
.btn-delete { background: #fef2f2; color: var(--danger); }

.login-footer {
    text-align: center;
    margin-top: 22px;
    color: var(--muted, #94a3b8);
    font-size: 0.82rem;
}

/* ---------------------------------------------------------
   ADMIN LAYOUT
   --------------------------------------------------------- */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-header {
    padding: 26px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .sb-logo {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header h2 { color: #fff; font-size: 1.25rem; line-height: 1.1; }
.sidebar-header span { font-size: 0.72rem; opacity: 0.6; display: block; }

.sidebar-menu { list-style: none; padding: 14px 0; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.92rem;
    font-weight: 500;
}

.sidebar-menu li a .sb-icon { width: 20px; text-align: center; font-size: 0.95rem; }

.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidebar-menu li.active a {
    background: rgba(14,159,110,0.15);
    color: #fff;
    border-left-color: var(--primary);
}

/* ---------------------------------------------------------
   MAIN CONTENT
   --------------------------------------------------------- */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px 34px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.topbar h1 { font-size: 1.6rem; letter-spacing: -0.01em; }

.user-info {
    color: var(--body);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent, #2563eb));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ---------------------------------------------------------
   STATS
   --------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all 0.25s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: #eff6ff;
}
.stat-icon.green { background: #f0fdf4; }
.stat-icon.orange { background: #fefce8; }
.stat-icon.red { background: #fef2f2; }
.stat-icon.purple { background: #f5f3ff; }
.stat-icon.teal { background: #f0fdfa; }

.stat-info h3 { font-size: 1.4rem; color: var(--ink); }
.stat-info p { color: var(--body); font-size: 0.84rem; }

/* ---------------------------------------------------------
   CARDS / DASHBOARD GRID
   --------------------------------------------------------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 25px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-header h3 { font-size: 1.1rem; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }

/* ---------------------------------------------------------
   TABLE
   --------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

.table thead th {
    background: var(--light);
    padding: 13px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--body);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody td {
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.unread td { background: #f0f9ff; font-weight: 500; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------
   BADGES
   --------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-success { background: #f0fdf4; color: var(--success); }
.badge-warning { background: #fefce8; color: var(--warning); }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-info { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.schedule-group {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}
.schedule-group.active {
    background: #f0f9ff;
    border-color: #38bdf8;
}

/* ---------------------------------------------------------
   FORMS
   --------------------------------------------------------- */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--ink);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.93rem;
    font-family: inherit;
    outline: none;
    background: #fff;
    color: var(--ink);
    transition: all 0.25s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,159,110,0.12);
}

.form-group small { color: var(--body); font-size: 0.8rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---------------------------------------------------------
   ALERTS
   --------------------------------------------------------- */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ---------------------------------------------------------
   FILTER BAR
   --------------------------------------------------------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------------------------------------------------------
   PAGINATION
   --------------------------------------------------------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 25px; }
.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.84rem;
    background: #fff;
}
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 992px) {
    .sidebar { width: 210px; }
    .main-content { margin-left: 210px; padding: 24px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; position: static; height: auto; }
    .main-content { margin-left: 0; }
    .admin-wrapper { flex-direction: column; }
    .sidebar-menu { display: flex; flex-wrap: wrap; }
    .sidebar-menu li a { padding: 10px 15px; border-left: none; border-bottom: 3px solid transparent; }
    .sidebar-menu li.active a { border-left: none; border-bottom-color: var(--primary); }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================
   ADDITIONAL ADMIN STYLES
   ========================================================= */

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* Table tools (search bar) */
.card-header .table-tools {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}
.table-tools input[type=text] {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 0.88rem;
    outline: none;
    min-width: 220px;
    transition: border-color 0.2s;
}
.table-tools input[type=text]:focus { border-color: var(--primary); }
.table-tools select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 0.88rem;
    background: #fff;
    outline: none;
}
.table-tools .btn { margin-left: auto; }

/* Post cell with thumbnail */
.post-cell { display: flex; align-items: center; gap: 10px; }
.post-thumb {
    width: 44px; height: 32px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--light);
}
.empty-cell { text-align: center; color: var(--body); padding: 30px !important; }
.topbar-count { color: var(--body); font-size: 0.9rem; font-weight: 500; }

.btn-view { background: #f8fafc; color: var(--ink); border: 1px solid var(--border); }

/* Current image preview */
.current-image { margin-bottom: 12px; }
.current-image img {
    max-width: 240px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
    margin-bottom: 8px;
}
.img-remove { font-size: 0.85rem; color: var(--danger); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.img-remove input { width: auto; }

/* Card grid improvements */
.dashboard-grid.two-col { grid-template-columns: 2fr 1fr; }

@media (max-width: 768px) {
    .table-tools input[type=text] { min-width: 100%; }
    .table-tools .btn { margin-left: 0; }
}

/* Dashboard quick actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.qa-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}
.qa-item:hover { background: #eef2ff; border-color: var(--primary); }

/* Mini messages list */
.mini-messages { list-style: none; margin: 0; padding: 0; }
.mini-messages li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
}
.mini-messages li:last-child { border-bottom: none; }
.mini-messages li span { color: var(--body); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-messages li small { color: #94a3b8; font-size: 0.75rem; }
.mini-messages li.none { color: var(--body); text-align: center; padding: 20px; }
.mini-messages li.unread { border-left: 3px solid var(--primary); padding-left: 8px; }

.stat-icon.gray { background: rgba(148,163,184,0.18); color: #64748b; }

/* =========================================================
   ADMIN UI POLISH v2
   ========================================================= */

/* Fonts + base */
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; line-height: 1.6; }
h1, h2, h3, h4 { font-family: 'Inter', sans-serif; letter-spacing: -0.01em; }

/* Sidebar refinements */
.sidebar { display: flex; flex-direction: column; transition: transform 0.3s ease; }
.sidebar-header h2 { font-family: 'Inter', sans-serif; }
.sidebar-menu { flex: 1; }
.sidebar-footer { padding: 14px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 22px; font-size: 0.92rem; font-weight: 500;
    border-left: 3px solid transparent; transition: all 0.2s;
    color: var(--sidebar-text);
}
.sidebar-footer-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-footer-link .sb-icon { width: 20px; text-align: center; font-size: 0.95rem; }
.link-danger:hover { color: #fca5a5; background: rgba(220,38,38,0.12); }

.sidebar-close { display: none; }

.sidebar-overlay { display: none; }

/* Mobile topbar for admin */
.admin-topbar-mobile {
    display: none;
    justify-content: space-between; align-items: center;
    gap: 12px; margin-bottom: 20px;
}
.admin-topbar-mobile .btn { padding: 10px 16px; font-size: 0.88rem; }
.topbar-mobile-brand { font-weight: 700; color: var(--ink); font-size: 1rem; }

/* Topbar actions */
.topbar { gap: 16px; flex-wrap: wrap; }
.topbar .btn { white-space: nowrap; }

/* Tables */
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .actions-cell { white-space: nowrap; text-align: right; }
.table .actions-cell .btn { margin: 2px 0; }
.msg-preview { color: var(--body); max-width: 260px; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    background: #fff; border-radius: 16px;
    width: 100%; max-width: 620px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex; flex-direction: column;
    max-height: 82vh;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    padding: 22px 26px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.15rem; margin-bottom: 4px; }
.modal-meta { color: var(--body); font-size: 0.83rem; }
.modal-close {
    background: none; border: none; font-size: 1.6rem; line-height: 1;
    color: var(--body); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 22px 26px; overflow-y: auto; flex: 1; white-space: pre-wrap; word-break: break-word; }
.modal-footer { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 26px; border-top: 1px solid var(--border); background: var(--light); }

/* Smaller helper tweaks */
.card-header form { width: 100%; }
.alert { display: flex; align-items: center; gap: 10px; }

/* Sortable/emphasize title cells */
.table td strong { color: var(--ink); }

/* Responsive admin */
@media (max-width: 992px) {
    .table { font-size: 0.85rem; }
    .table thead th { font-size: 0.78rem; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 270px; position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-105%);
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.4); }
    .sidebar-close {
        display: flex; margin-left: auto;
        width: 32px; height: 32px; border-radius: 8px;
        background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
        color: #fff; font-size: 1.2rem; cursor: pointer; align-items: center; justify-content: center;
    }
    .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 45; opacity: 0; visibility: hidden; transition: all 0.3s; }
    .sidebar-overlay.open { opacity: 1; visibility: visible; }
    .admin-topbar-mobile { display: flex; }
    .main-content { margin-left: 0; padding: 20px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .topbar h1 { font-size: 1.35rem; }
    .actions-cell { text-align: left !important; }
}
