/* VungTien Admin — ArchitectUI-inspired theme (light variant).
 *
 * Visual idiom borrowed from
 *   github.com/DashboardPack/architectui-html-theme-free  (MIT)
 * with a hand-rolled CSS layer so we don't need the SASS pipeline.
 * Colour palette and the sidebar + top header + card stack pattern
 * match the upstream demo; spacing tightened for a denser dashboard.
 */

:root {
    --primary:   #3f6ad8;
    --primary-dark: #2f55b4;
    --secondary: #6c757d;
    --success:   #3ac47d;
    --warning:   #f7b924;
    --danger:    #d92550;
    --info:      #16aaff;
    --bg-app:    #f1f4f6;
    --bg-card:   #ffffff;
    --bg-sidebar:#2b3553;
    --bg-sidebar-active: #1f2a48;
    --bg-header: #ffffff;
    --text-default: #2c3e50;
    --text-muted: #6c757d;
    --border:    #e0e6ed;
    --shadow-sm: 0 0.46875rem 2.1875rem rgba(4,9,20,0.03),
                 0 0.9375rem 1.40625rem rgba(4,9,20,0.03),
                 0 0.25rem 0.53125rem rgba(4,9,20,0.05),
                 0 0.125rem 0.1875rem rgba(4,9,20,0.03);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-app);
    color: var(--text-default);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ----- Top header ----- */
.app-header {
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    position: sticky; top: 0; z-index: 1000;
}
.app-header__brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-default); font-weight: 600;
}
.brand-mark {
    width: 36px; height: 36px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
}
.brand-logo {
    width: 38px; height: 38px;
    object-fit: contain;
    border-radius: 6px;
}
.brand-text { font-size: 16px; }

.app-header__menu .btn-outline-light {
    color: var(--text-default);
    border-color: var(--border);
}
.app-header__menu .btn-outline-light:hover {
    background: var(--bg-app);
    color: var(--primary);
    border-color: var(--border);
}
.user-badge {
    color: var(--text-muted);
    font-size: 13px;
}
.user-badge strong { color: var(--text-default); font-weight: 600; }
.badge-role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-app);
    color: var(--text-muted);
}
.badge-role.role-superadmin { background: rgba(217,37,80,0.12); color: var(--danger); }
.badge-role.role-admin      { background: rgba(63,106,216,0.12); color: var(--primary); }
.badge-role.role-user       { background: rgba(108,117,125,0.15); color: var(--secondary); }

/* ----- Layout ----- */
.app-container { display: flex; min-height: calc(100vh - 60px); }
.app-sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    flex-shrink: 0;
    padding: 20px 0;
}
.app-main { flex: 1; padding: 28px 32px; overflow-x: auto; }

/* ----- Sidebar nav ----- */
.vertical-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 18px 22px 6px;
    text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 22px;
    color: rgba(255,255,255,0.78);
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: #fff;
    text-decoration: none;
}
.nav-item.active {
    background: var(--bg-sidebar-active);
    color: #fff;
    border-left-color: var(--info);
}
.nav-item i { width: 18px; text-align: center; opacity: 0.85; }

/* ----- Page heading ----- */
.page-title {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 24px;
}
.page-title__icon {
    width: 44px; height: 44px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.page-title__main { display: flex; flex-direction: column; }
.page-title h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text-default); }
.page-title__sub { color: var(--text-muted); font-size: 13px; }

/* ----- Cards ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-default);
    background: transparent;
}
.card-body { padding: 18px 20px; }

/* ----- Stat cards (KPI strip) ----- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.stat-card__label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 6px;
}
.stat-card__value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-default);
    line-height: 1.1;
}
.stat-card__icon {
    position: absolute;
    right: 18px; top: 18px;
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: #fff;
}
.stat-card.primary .stat-card__icon { background: var(--primary); }
.stat-card.success .stat-card__icon { background: var(--success); }
.stat-card.warning .stat-card__icon { background: var(--warning); }
.stat-card.danger  .stat-card__icon { background: var(--danger);  }
.stat-card.info    .stat-card__icon { background: var(--info);    }
.stat-card.secondary .stat-card__icon { background: var(--secondary); }

/* ----- Tables ----- */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table thead th {
    background: #f7f9fb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f3f5;
    color: var(--text-default);
}
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table tbody tr:hover { background: #fafbfc; }

.mono { font-family: "Consolas", "Menlo", monospace; font-size: 12px; }
.muted { color: var(--text-muted); }
.err { color: var(--danger); font-weight: 500; }

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge.active   { background: rgba(58,196,125,0.12); color: var(--success); }
.badge.unbound  { background: rgba(247,185,36,0.15); color: #b07c00; }
.badge.revoked,
.badge.red      { background: rgba(217,37,80,0.12); color: var(--danger); }

/* ----- Buttons (override Bootstrap subtly) ----- */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-danger { background-color: var(--danger); border-color: var(--danger); }
.btn-success { background-color: var(--success); border-color: var(--success); }

/* Forms */
.form-row {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin-bottom: 18px;
}
.form-row .form-control, .form-row .form-select {
    width: auto;
    min-width: 220px;
}

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.flash.ok  { background: rgba(58,196,125,0.10); color: #1e7e4f; border-color: rgba(58,196,125,0.30); }
.flash.err { background: rgba(217,37,80,0.10); color: #8a1c3b; border-color: rgba(217,37,80,0.30); }

/* Detail page — definition list rendered as 2-column grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.detail-grid .card { margin-bottom: 0; }
dl.detail-list { margin: 0; display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
dl.detail-list dt { color: var(--text-muted); font-weight: 500; }
dl.detail-list dd { margin: 0; color: var(--text-default); word-break: break-all; }

.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted); font-size: 13px;
    margin-bottom: 14px;
}
.back-link:hover { color: var(--primary); }

/* Login (centered card) */
body.login-page {
    background: linear-gradient(135deg, #3f6ad8 0%, #16aaff 100%);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; margin: 0;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 42px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 380px;
    display: flex; flex-direction: column; gap: 14px;
}
.login-card .login-brand {
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 6px;
}
.login-logo {
    max-width: 220px;
    width: 100%;
    height: auto;
    object-fit: contain;
}
.login-card h1 { margin: 0; font-size: 18px; font-weight: 600; }
.login-card .form-control {
    padding: 10px 14px;
}
.login-card .btn-primary { padding: 10px 14px; font-weight: 500; }

/* Misc */
.hint { color: var(--text-muted); font-size: 13px; padding: 18px 0; }
@media (max-width: 900px) {
    .app-sidebar { display: none; }
    .app-main { padding: 18px; }
    .detail-grid { grid-template-columns: 1fr; }
}
