/* =========================================
   UNIVERSAL MASTER CSS (API Hub) - FIXED
========================================= */

/* ---------- 1. CORE VARIABLES ---------- */
:root {
    --bg: #fafbfc;
    --surface: #ffffff;
    --border: #eef1f5;
    --border-strong: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --primary: #0f172a;
    --primary-hover: #1e293b;
    --success: #027a48;
    --danger: #b42318;
    --warning: #b54708;
    --radius: 12px;
    --radius-sm: 8px;
}

/* ---------- 2. BASE RESET ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ---------- 3. MAIN LAYOUT ---------- */
.app-container { display: flex; min-height: 100vh; width: 100%; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow-y: auto; }
.main-content { flex: 1; padding: 30px 40px; background: var(--bg); }

/* ---------- 4. SIDEBAR & TOPBAR (DESKTOP) ---------- */
.sidebar { 
    width: 260px; 
    background: var(--surface); 
    border-right: 1px solid var(--border); 
    padding: 24px 16px; 
    flex-shrink: 0; 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    position: sticky; 
    top: 0; 
}
.sidebar .logo h2 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 30px; padding-left: 10px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--text-muted); transition: 0.2s ease; margin-bottom: 4px; }
.sidebar a:hover, .sidebar a.active { background: #f1f5f9; color: var(--text); }

/* HIDE MOBILE ELEMENTS ON DESKTOP */
.mobile-header, .close-btn, .sidebar-overlay { display: none; }

.topbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; flex-shrink: 0; position: sticky; top: 0; z-index: 50; }
.topbar-right { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.topbar-wallet { display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 6px 14px; border-radius: 50px; border: 1px solid var(--border); font-size: 13.5px; }
.wallet-amount { font-weight: 700; color: var(--success); }

/* Profile Dropdown */
.profile-menu { position: relative; }
.profile-btn { background: none; border: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.profile-btn:hover { background: var(--bg); }
.avatar { width: 32px; height: 32px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; margin-top: 8px; background: var(--surface); min-width: 200px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); border-radius: var(--radius-sm); border: 1px solid var(--border); z-index: 100; }
.profile-menu:hover .dropdown-content { display: block; }
.dropdown-header { padding: 16px; border-bottom: 1px solid var(--border); }
.dropdown-content a { display: block; padding: 12px 16px; font-size: 13.5px; font-weight: 500; transition: 0.2s; }
.dropdown-content a:hover { background: var(--bg); }

/* ---------- 5. PAGE HEADERS & CARDS ---------- */
.page-top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
.page-top-header h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-top-header p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.breadcrumb { font-size: 13px; color: var(--text-muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.card-header { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* Dashboard Stats Boxes */
.summary-boxes { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.summary-box { flex: 1; min-width: 200px; padding: 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.summary-box.bg-light-green { background: #ecfdf3; border-color: #d1fadf; }
.summary-box.bg-light-red { background: #fef3f2; border-color: #fee4e2; }
.box-title { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.box-amount { font-size: 24px; font-weight: 700; color: var(--text); }

/* ---------- 6. TABLES ---------- */
.table-responsive { overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; padding: 14px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); }
td { padding: 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* ---------- 7. BUTTONS ---------- */
.btn { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); padding: 8px 16px; font-size: 13.5px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: #f1f5f9; }
.btn-primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ---------- 8. FORMS & INPUTS ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control, .filter-input { width: 100%; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 14px; background: var(--surface); color: var(--text); outline: none; transition: 0.2s; }
.form-control:focus, .filter-input:focus { border-color: var(--text-soft); box-shadow: 0 0 0 3px rgba(148,163,184,0.1); }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- 9. BADGES & PILLS ---------- */
.badge-pill { padding: 4px 10px; border-radius: 50px; font-size: 11.5px; font-weight: 600; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-success { background: #ecfdf3; color: var(--success); border: 1px solid #d1fadf; }
.badge-danger { background: #fef3f2; color: var(--danger); border: 1px solid #fee4e2; }
.badge-warning { background: #fff8f1; color: var(--warning); border: 1px solid #ffebd3; }
.badge-neutral { background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- 10. UTILITIES ---------- */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }

.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.font-medium { font-weight: 500 !important; }
.text-sm { font-size: 12.5px !important; }
.text-center { text-align: center !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-20 { margin-top: 20px !important; }

.text-stack { display: flex; flex-direction: column; gap: 4px; }
.text-wrap { white-space: normal !important; line-height: 1.4; max-width: 300px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-soft); font-size: 15px; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; }

/* ---------- 11. MOBILE RESPONSIVE (Slide & Toggle fixed) ---------- */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    
    /* Topbar & Desktop adjustments */
    .topbar { display: none !important; }
    .main-wrapper { height: auto; overflow: visible; }
    .main-content { padding: 20px 16px; }
    .page-top-header { flex-direction: column; align-items: flex-start; }
    .filter-row { flex-direction: column; width: 100%; align-items: stretch; }
    
    /* Mobile Header (Hamburger) */
    .mobile-header { display: flex; justify-content: space-between; align-items: center; background: var(--surface); padding: 15px 20px; border-bottom: 1px solid var(--border); }
    .mobile-header h2 { margin: 0; font-size: 20px; color: var(--text); font-weight: 700; }
    .hamburger { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); padding: 5px; }
    
    /* Mobile Sidebar Sliding Logic */
    .sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 260px; z-index: 1000; transform: translateX(-100%); transition: transform 0.3s ease-in-out; box-shadow: 2px 0 15px rgba(0,0,0,0.2); }
    .sidebar.active { transform: translateX(0); }
    
    /* ✖ Close Button & Overlay */
    .close-btn { display: block; background: none; border: none; font-size: 18px; position: absolute; top: 20px; right: 20px; cursor: pointer; color: var(--text-muted); }
    .sidebar-overlay { display: block; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); z-index: 999; opacity: 0; visibility: hidden; transition: 0.3s; }
    .sidebar-overlay.active { opacity: 1; visibility: visible; }
}

/* =========================================
   PAGE SPECIFIC STYLES
========================================= */

/* --- Wallet History Page --- */
.tx-header-container {
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 20px; 
    margin-bottom: 24px;
}
.tx-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}
@media (max-width: 1024px) {
    .tx-header-container { flex-direction: column; align-items: flex-start; }
    .tx-filter-form { flex-wrap: wrap; width: 100%; }
    .tx-filter-form input { flex: 1; min-width: 130px; }
}

/* --- API Users Page --- */
.user-action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 6px; 
    min-width: 140px; 
    max-width: 180px; 
}
.btn-action {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    padding: 4px 6px; 
    border-radius: 4px;
    font-size: 11px; 
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap; 
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    height: 26px; 
}
.btn-action:hover {
    background: #f1f5f9;
    color: var(--text);
}
.btn-action.delete:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: #fef3f2; 
}
.btn-action.manage {
    grid-column: span 2;
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--border-strong);
    height: 28px; 
}
.btn-action.manage:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}
.p-0 { padding: 0 !important; }
.mt-4 { margin-top: 4px !important; }

/* =========================================
   --- NEWLY ADDED: Settings & Profile Page --- 
========================================= */
.form-section { 
    margin-bottom: 40px; 
}
.form-section:last-of-type { 
    margin-bottom: 0; 
}
.form-section-title { 
    font-size: 15px; 
    font-weight: 600; 
    color: var(--text); 
    margin: 0 0 20px 0; 
    padding-bottom: 12px; 
    border-bottom: 1px solid var(--border); 
}

.settings-grid { 
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 24px; 
    align-items: flex-start;
}

.form-text { 
    display: block; 
    font-size: 12px; 
    color: var(--text-soft); 
    margin-bottom: 8px; 
    line-height: 1.3; 
    min-height: 32px; 
}

/* Specific inputs for forms (like Settings) */
.form-group input, .form-group select { 
    width: 100%; 
    padding: 10px 14px; 
    border: 1px solid var(--border-strong); 
    border-radius: var(--radius-sm); 
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: all 0.2s ease;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}

.form-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.alert-box {
    padding: 10px 16px; 
    border-radius: var(--radius-sm); 
    display: none;
    background: #ecfdf3; 
    border: 1px solid #d1fadf; 
    color: var(--success);
    font-size: 13.5px; 
    font-weight: 500;
}

/* Mobile & Tablet Responsive for Settings Page */
@media (max-width: 1024px) {
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
    .form-text { min-height: auto; margin-bottom: 4px; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; text-align: center; }
}