/* ==========================================================================
   TPQ Abdul Halim — Custom Dashboard Styles
   ========================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #1d4ed8;
    --sidebar-section: #64748b;
    --topbar-height: 64px;
    --footer-height: 48px;
    --content-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --card-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.admin-body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--content-bg);
    color: #0f172a;
    overflow-x: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.admin-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.25s ease-in-out;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-brand-text .brand-title {
    color: #fff; font-weight: 700; font-size: 0.95rem; line-height: 1.2;
}
.sidebar-brand-text .brand-subtitle {
    color: #94a3b8; font-size: 0.75rem;
}

.sidebar-nav { padding: 0.75rem 0.75rem 2rem; }

.sidebar-nav .nav-section {
    color: var(--sidebar-section);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1rem 0.85rem 0.35rem;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex; align-items: center; gap: 0.7rem;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

/* ==========================================================================
   Main layout
   ========================================================================== */
.admin-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease-in-out;
}

.admin-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1030;
}

.topbar-title {
    font-size: 1.15rem; font-weight: 600; margin: 0; color: #0f172a;
}

.btn-icon {
    background: transparent; border: 0; color: #475569; padding: 0.4rem 0.6rem;
    font-size: 1.2rem; border-radius: 6px;
}
.btn-icon:hover { background: #f1f5f9; }

.btn-user {
    background: transparent; border: 0;
    display: flex; align-items: center; gap: 0.6rem;
    color: #0f172a; padding: 0.35rem 0.6rem; border-radius: 8px;
}
.btn-user:hover { background: #f1f5f9; }
.btn-user::after { margin-left: 0.25rem; }

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem;
}

.user-name { font-size: 0.9rem; font-weight: 500; }

.admin-content {
    flex: 1;
    padding: 1.5rem;
}

.admin-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem;
    min-height: var(--footer-height);
    display: flex; align-items: center;
}

/* ==========================================================================
   Cards / Stats
   ========================================================================== */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    display: flex; align-items: center; gap: 1rem;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}
.stat-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}
.stat-icon.bg-primary-soft { background: rgba(29, 78, 216, 0.1); color: var(--primary); }
.stat-icon.bg-success-soft { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.stat-icon.bg-warning-soft { background: rgba(217, 119, 6, 0.1); color: var(--warning); }
.stat-icon.bg-info-soft    { background: rgba(8, 145, 178, 0.1);  color: var(--info); }
.stat-icon.bg-danger-soft  { background: rgba(220, 38, 38, 0.1);  color: var(--danger); }

.stat-value { font-size: 1.6rem; font-weight: 700; color: #0f172a; line-height: 1.1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }

.content-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}
.content-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap;
}
.content-card .card-header h5,
.content-card .card-header h6 { margin: 0; font-weight: 600; }
.content-card .card-body { padding: 1.25rem; }
.content-card .card-footer { background: transparent; border-top: 1px solid var(--border-color); padding: 1rem 1.25rem; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: 0.85rem 1rem; }
.table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
}
.table tbody tr { border-bottom: 1px solid #f1f5f9; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }

/* Pagination */
.content-card .card-footer .pagination { margin-bottom: 0; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge-status { font-weight: 500; padding: 0.35em 0.7em; font-size: 0.75rem; }
.badge-hadir { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.badge-izin  { background: rgba(8, 145, 178, 0.12);  color: var(--info); }
.badge-sakit { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.badge-alpha { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.badge-success-soft { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.badge-danger-soft  { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.badge-warning-soft { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.badge-secondary-soft { background: rgba(100, 116, 139, 0.12); color: #475569; }

/* ==========================================================================
   Buttons (subtle overrides)
   ========================================================================== */
.btn { font-weight: 500; border-radius: 8px; }
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-label { font-weight: 500; color: #334155; font-size: 0.9rem; margin-bottom: 0.4rem; }
.form-control, .form-select { border-radius: 8px; border-color: var(--border-color); }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(29, 78, 216, 0.12);
}

/* ==========================================================================
   Auth (Login) page
   ========================================================================== */
body.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}

.auth-wrapper { width: 100%; max-width: 420px; }

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.25rem 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.auth-header { text-align: center; margin-bottom: 1.75rem; }
.auth-logo {
    width: 64px; height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 2rem; margin-bottom: 1rem;
}
.auth-title { font-size: 1.5rem; font-weight: 700; color: #0f172a; margin: 0; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

.auth-card .form-control {
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
}
.auth-card .input-group-text {
    background: #f8fafc; border-color: var(--border-color); color: var(--text-muted);
}
.auth-card .btn-primary { padding: 0.65rem; font-weight: 600; }

/* ==========================================================================
   WAHA Gateway
   ========================================================================== */
.wa-status-pill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0.8rem; border-radius: 999px;
    font-size: 0.8rem; font-weight: 500;
}
.wa-status-pill .dot {
    width: 8px; height: 8px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}
.wa-status-connected { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.wa-status-disconnected { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.wa-status-warning { background: rgba(217, 119, 6, 0.12); color: var(--warning); }

.wa-status-icon { font-size: 2.25rem; line-height: 1; }

.wa-steps { line-height: 1.7; }
.wa-steps li { margin-bottom: 0.15rem; }

.qr-wrapper {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
}
.qr-wrapper img { max-width: 220px; height: auto; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 767.98px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 1rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.3rem; }
}
