/* ============================================================
   PHP Portal Hub — Admin Panel Styles
   Responsive sidebar layout, modern & clean
   ============================================================ */

:root {
    --primary: #6366f1;
    --accent: #8b5cf6;
    --primary-rgb: 99, 102, 241;
    --bg: #f4f6fb;
    --bg-elev: #ffffff;
    --bg-soft: #eef1f8;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e5e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .22);
    --radius: 14px;
    --radius-sm: 10px;
    --font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sidebar-w: 264px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Layout ---------- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); background: var(--sidebar); color: #cbd5e1;
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 60;
    transition: transform .3s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand .logo {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; flex-shrink: 0;
}
.sidebar-brand .logo svg { width: 22px; height: 22px; }
.sidebar-brand b { color: #fff; font-size: 1rem; letter-spacing: -.01em; display: block; }
.sidebar-brand small { font-size: .72rem; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 8px; font-weight: 700; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
    color: #cbd5e1; font-weight: 500; font-size: .92rem; margin-bottom: 3px; transition: all .18s ease;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 8px 18px -8px rgba(var(--primary-rgb), .9); }
.nav-item .pill { margin-left: auto; font-size: .72rem; background: rgba(255,255,255,.14); padding: 2px 8px; border-radius: 999px; }

.sidebar-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user .meta b { color: #fff; font-size: .88rem; display: block; }
.sidebar-user .meta small { color: #94a3b8; font-size: .74rem; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 68px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px;
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { font-size: .82rem; color: var(--text-muted); font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }

.content { padding: 26px 24px 48px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: .9rem;
    border: 1px solid transparent; cursor: pointer; transition: all .18s ease; white-space: nowrap; font-family: inherit;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 8px 18px -8px rgba(var(--primary-rgb), .8); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgba(var(--primary-rgb), .9); }
.btn-ghost { background: var(--bg-elev); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--bg-elev); color: var(--text); display: grid; place-items: center; cursor: pointer; transition: all .18s ease;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Cards & panels ---------- */
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; }
.panel-head p { font-size: .84rem; color: var(--text-muted); }
.panel-body { padding: 22px; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 16px; transition: transform .2s ease;
}
.stat:hover { transform: translateY(-3px); }
.stat .ic { width: 50px; height: 50px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ic svg { width: 24px; height: 24px; }
.stat .ic.indigo { background: rgba(99,102,241,.12); color: #6366f1; }
.stat .ic.green { background: rgba(34,197,94,.12); color: #16a34a; }
.stat .ic.amber { background: rgba(245,158,11,.12); color: #d97706; }
.stat .ic.rose { background: rgba(244,63,94,.12); color: #e11d48; }
.stat .ic.sky { background: rgba(14,165,233,.12); color: #0284c7; }
.stat .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .lbl { font-size: .82rem; color: var(--text-muted); font-weight: 500; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
    text-align: left; padding: 13px 16px; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--bg-soft); white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }
.cell-portal { display: flex; align-items: center; gap: 12px; }
.cell-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.cell-icon svg { width: 20px; height: 20px; }
.cell-portal b { font-weight: 600; display: block; }
.cell-portal small { color: var(--text-muted); font-size: .78rem; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.on { background: rgba(34,197,94,.14); color: #16a34a; }
.badge.off { background: rgba(100,116,139,.14); color: #64748b; }
.badge.feat { background: rgba(245,158,11,.16); color: #d97706; }
.badge.cat { background: var(--bg-soft); color: var(--text-muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 600; }
.field label .req { color: var(--danger); }
.field .hint { font-size: .76rem; color: var(--text-muted); }
.input, .select, .textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
    font-size: .92rem; font-family: inherit; background: var(--bg-elev); color: var(--text); transition: all .18s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .13); }
.textarea { resize: vertical; min-height: 100px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }

.switch { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s ease; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s ease; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .txt b { font-size: .88rem; display: block; }
.switch .txt small { font-size: .76rem; color: var(--text-muted); }

/* Icon picker */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; max-height: 190px; overflow-y: auto; padding: 4px; }
.icon-opt {
    aspect-ratio: 1; border: 1px solid var(--border); border-radius: 10px; display: grid; place-items: center;
    cursor: pointer; color: var(--text-muted); transition: all .15s ease; background: var(--bg-elev);
}
.icon-opt:hover { border-color: var(--primary); color: var(--primary); }
.icon-opt.selected { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-color: transparent; }
.icon-opt svg { width: 20px; height: 20px; }

.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=color] { width: 48px; height: 44px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--bg-elev); padding: 3px; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- Login page ---------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(50% 50% at 20% 10%, rgba(99,102,241,.22), transparent 70%),
        radial-gradient(50% 50% at 85% 90%, rgba(139,92,246,.2), transparent 70%),
        var(--bg);
}
.login-card { width: 100%; max-width: 420px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 32px; }
.login-logo { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; margin: 0 auto 20px; box-shadow: 0 12px 26px -10px rgba(var(--primary-rgb), .9); }
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { text-align: center; font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.demo-note { margin-top: 20px; padding: 13px 16px; border-radius: 10px; background: rgba(99,102,241,.08); border: 1px dashed rgba(99,102,241,.4); font-size: .82rem; color: var(--text-muted); text-align: center; }
.demo-note b { color: var(--primary); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 10px; font-size: .88rem; margin-bottom: 18px; font-weight: 500; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert.success { background: rgba(34,197,94,.1); color: #15803d; border: 1px solid rgba(34,197,94,.3); }
.alert.error { background: rgba(239,68,68,.1); color: #b91c1c; border: 1px solid rgba(239,68,68,.3); }
.alert.warning { background: rgba(245,158,11,.1); color: #b45309; border: 1px solid rgba(245,158,11,.3); }
.alert.info { background: rgba(99,102,241,.1); color: #4338ca; border: 1px solid rgba(99,102,241,.3); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 16px; opacity: .35; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .search-mini { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.toolbar .search-mini svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); }
.toolbar .search-mini input { padding-left: 42px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: grid; }
.modal { background: var(--bg-elev); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; padding: 26px; animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.modal h3 { font-size: 1.15rem; margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: .9rem; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 20px 16px 40px; }
    .topbar { padding: 0 16px; }
}
@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat { padding: 16px; gap: 12px; }
    .stat .num { font-size: 1.4rem; }
    .topbar h1 { font-size: 1rem; }
    .topbar .sub { display: none; }
    .login-card { padding: 28px 22px; }
    .row-actions { flex-direction: column; }
}
@media (max-width: 400px) {
    .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- Overlay for mobile sidebar ---------- */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55; display: none; }
.sidebar-overlay.open { display: block; }
