/* am-thuc.com — Modern SaaS UI
   Mobile-first, inspired by TuPhap Platform
   Color: green #00a859 */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #00a859;
    --primary-dark: #008a49;
    --primary-light: #e8f5ee;
    --primary-bg: #f0faf5;
    --header-bg: #2d5f3f;
    --header-text: #ffffff;
    --body-bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1a2b3c;
    --text-secondary: #6b7d8e;
    --text-muted: #9aa8b5;
    --border: #e8ecf0;
    --border-light: #f0f3f6;
    --danger: #e74c3c;
    --danger-bg: #fff0ef;
    --warning: #f39c12;
    --warning-bg: #fef9ed;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --bottom-nav-h: 64px;
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; color: var(--text); background: var(--body-bg);
    line-height: 1.5; padding-bottom: var(--bottom-nav-h);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== TOP BAR ===== */
.topbar {
    background: var(--header-bg); color: var(--header-text);
    padding: 0 16px; height: 56px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 100;
}
.topbar-hamburger {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.15); border: none; border-radius: 8px;
    color: #fff; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.topbar-hamburger:hover { background: rgba(255,255,255,0.25); }
.topbar-brand {
    font-size: 17px; font-weight: 700; flex: 1;
    display: flex; align-items: center; gap: 8px;
}
.topbar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions button, .topbar-actions a {
    width: 36px; height: 36px; border-radius: 8px;
    background: rgba(255,255,255,0.12); border: none;
    color: #fff; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,0.3);
}

/* Impersonation banner */
.impersonation-bar {
    background: var(--warning); color: #fff;
    padding: 8px 16px; font-size: 13px;
    display: flex; align-items: center; justify-content: space-between;
}
.impersonation-bar a { color: #fff; font-weight: 700; text-decoration: underline; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h); background: #fff;
    border-top: 1px solid var(--border);
    display: flex; z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px;
    color: var(--text-muted); text-decoration: none; font-size: 11px; position: relative;
}
.bottom-nav a .nav-icon { font-size: 22px; line-height: 1; }
.bottom-nav a.active { color: var(--primary); font-weight: 600; }
.bottom-nav a.active::after {
    content: ''; position: absolute; top: 0; left: 25%; right: 25%;
    height: 3px; background: var(--primary); border-radius: 0 0 3px 3px;
}
.bottom-nav .nav-badge {
    position: absolute; top: 4px; right: calc(50% - 20px);
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    padding: 1px 5px; border-radius: 10px; line-height: 1.3;
}

/* ===== HAMBURGER MENU OVERLAY ===== */
.menu-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 200; }
.menu-overlay.open { display: block; }
.menu-panel {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: 300px; max-width: 85vw;
    background: #fff; overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.menu-header { background: var(--header-bg); color: #fff; padding: 20px 16px; position: relative; }
.menu-header .user-name { font-size: 18px; font-weight: 700; }
.menu-header .user-role { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.menu-header .close-btn {
    position: absolute; top: 12px; right: 12px;
    background: rgba(255,255,255,0.2); border: none; color: #fff;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 18px;
}
.menu-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 1px; background: var(--border-light); padding: 1px;
}
.menu-grid a {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 8px; background: #fff;
    color: var(--text); text-decoration: none; font-size: 12px; text-align: center;
}
.menu-grid a:hover { background: var(--primary-light); text-decoration: none; }
.menu-grid a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.menu-grid .menu-icon { font-size: 24px; }
.menu-section {
    padding: 10px 16px 4px; font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
    background: var(--body-bg); grid-column: 1 / -1;
}

.branch-selector { padding: 12px 16px; background: var(--primary-bg); border-bottom: 1px solid var(--border); }
.branch-selector select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: #fff; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 16px; max-width: 1200px; margin: 0 auto; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); border-left: 4px solid var(--primary); box-shadow: var(--shadow); }
.stat-card .label { color: var(--text-secondary); font-size: 12px; display: flex; align-items: center; justify-content: space-between; }
.stat-card .label .stat-icon { font-size: 20px; opacity: 0.6; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 6px; color: var(--text); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); background: var(--warning-bg); }
.stat-card.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.stat-card.success { border-left-color: var(--success); background: var(--success-bg); }

/* ===== CARDS ===== */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: #fafbfc; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #fafbfc; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 11px; letter-spacing: 0.3px; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafb; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); cursor: pointer; font-size: 13px; text-decoration: none; transition: all 0.15s; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f4f6f8; text-decoration: none; box-shadow: var(--shadow); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: #fff; transition: border-color 0.15s, box-shadow 0.15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,168,89,0.12); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 140px; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f1f5f9; color: #475569; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; align-items: center; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.toolbar .search-box { flex: 1; max-width: 300px; }
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== LOGIN ===== */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--header-bg), var(--primary)); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 26px; color: var(--primary); font-weight: 800; }
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* ===== UTILITY ===== */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mt-2 { margin-top: 16px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.required { color: var(--danger); }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

@media (min-width: 769px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .bottom-nav { display: none; }
    body { padding-bottom: 0; }
    .page-content { padding: 24px; }
}
@media (max-width: 768px) {
    .page-content { padding: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 20px; }
    .form-row { flex-direction: column; }
}
