@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0086d4;
    --primary-light: rgba(0, 134, 212, 0.1);
    --secondary: #0f172a;
    --sidebar-bg: #ffffff;
    --main-bg: #f8fafc;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    --success: #10b981;
    --danger: #ef4444;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--main-bg);
    color: var(--text-dark);
    line-height: 1.5;
    margin: 0;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
}

@media (min-width: 992px) {
    body.sidebar-desktop-collapsed .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .main-content {
        transition: margin-left 0.3s ease, width 0.3s ease;
    }

    body.sidebar-desktop-collapsed .main-content {
        margin-left: 0 !important;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.brand-icon {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.brand-name {
    font-weight: 700;
    font-size: 18px;
    color: var(--secondary);
}

.brand-name span {
    display: block;
    font-weight: 400;
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar nav {
    padding: 0 16px;
}

.nav-category {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 20px 0 8px 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    text-decoration: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    color: #64748b;
    opacity: 0.8;
}

.nav-link:hover {
    background: #f8fafc;
    color: var(--primary);
}

.nav-link.active {
    background: #e0f2fe;
    color: var(--primary);
}

.nav-link.active i {
    color: var(--primary);
    opacity: 1;
}

.nav-link.logout {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    color: #ef4444;
}

.nav-link.logout:hover {
    background: #fef2f2;
    border-radius: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary);
}

.page-header p {
    color: var(--text-muted);
    font-size: 15px;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

/* Welcome Banner */
.welcome-banner {
    background: #0086d4;
    color: white;
    padding: 24px 32px;
    border-radius: 16px;
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.welcome-info h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-info p {
    opacity: 0.9;
    font-size: 15px;
    margin-bottom: 20px;
}

.api-key-badge {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    padding: 10px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: monospace;
    font-size: 14px;
    max-width: fit-content;
}

.api-key-badge span {
    letter-spacing: 1px;
}

.copy-icon {
    cursor: pointer;
    opacity: 0.8;
}

.copy-icon:hover { opacity: 1; }

.balance-card {
    text-align: right;
}

.balance-card span {
    display: block;
    font-size: 14px;
    opacity: 0.8;
}

.balance-card h3 {
    font-size: 32px;
    font-weight: 700;
    margin: 4px 0 16px;
}

.btn-topup {
    background: white;
    color: var(--primary);
    border: none;
    padding: 8px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Quick Actions & Stats Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.action-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.action-details h4 {
    font-size: 15px;
    font-weight: 700;
}

.action-details p {
    font-size: 13px;
    color: var(--text-muted);
}

.stats-card {
    position: relative;
}

.stats-card .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
}

.stats-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--secondary);
}

.stats-trend {
    position: absolute;
    right: 24px;
    top: 24px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Success Rate Progress */
.rate-container {
    margin-top: 12px;
}

.progress-bar {
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 4px;
}

/* Lists & Charts */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.section-header a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.api-call-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.api-call-item:last-child { border: none; }

.call-info h5 {
    font-size: 14px;
    font-weight: 600;
}

.call-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.call-status {
    text-align: right;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.status-badge.success { background: #ecfdf5; color: #059669; }
.status-badge.error { background: #fef2f2; color: #dc2626; }

.call-time {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Toast Notification (Keep existing) */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
}

.toast {
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 6px solid var(--primary);
    min-width: 320px;
}

.toast.show { transform: translateX(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast-msg { font-size: 14px; font-weight: 600; color: var(--secondary); }

/* Auth Pages (Special Handling since style.css is shared) */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--main-bg);
}

.auth-card {
    background: white;
    width: 100%;
    max-width: 440px;
    padding: 48px 40px;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    text-align: center;
}

/* Adjustments for Auth inputs in new style */
.pin-wrapper { display: flex; gap: 8px; margin: 24px 0; }
.pin-box { 
    flex: 1; height: 60px; border: 1.5px solid var(--border-color); 
    border-radius: 12px; text-align: center; font-size: 24px; font-weight: 700;
}
.pin-box:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px var(--primary-light); }
.subtitle { color: var(--text-muted); font-size: 15px; margin-bottom: 32px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; font-weight: 500; display: none; }

/* Form & Tester UI Enhancements */
.form-control {
    width: 100%;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    color: var(--text-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.badge-status {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

.badge-status.method-get { background: #eff6ff; color: #3b82f6; }
.badge-status.method-post { background: #ecfdf5; color: #10b981; }

.tester-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.result-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.code-view {
    background: #1e293b;
    color: #38bdf8;
    padding: 24px;
    border-radius: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    margin-top: 16px;
    flex-grow: 1;
}

.endpoint-url {
    background: #f1f5f9;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: monospace;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-reset {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-reset:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-1px);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #0086d4 0%, #0075ba 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 134, 212, 0.25);
    width: auto;
    min-height: 50px;
    letter-spacing: 0.02em;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0294e8 0%, #0086d4 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 134, 212, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary i {
    font-size: 14px;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    height: 48px;
    padding: 0 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
}

.mobile-header .brand { margin: 0; gap: 8px; padding: 0; border-bottom: none; line-height: 1; display: flex; align-items: center; }
.mobile-header .brand-icon { width: 20px; height: 20px; font-size: 10px; border-radius: 4px; }
.mobile-header .brand-name { font-size: 13px; line-height: 1; }
.mobile-header .brand-name span { display: block; font-size: 8px; font-weight: 500; opacity: 0.6; line-height: 1; margin-top: 1px; }

.menu-toggle {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-dark);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SQL Autocomplete & History Styles */
.suggestion-box {
    position: absolute;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    max-height: 250px;
    overflow-y: auto;
    width: 100%; /* Lebar pas dengan textarea */
    display: none;
    bottom: calc(100% + 4px); /* Pindah ke atas */
    left: 0;
    padding: 6px 0;
}

.suggestion-box::-webkit-scrollbar {
    width: 6px;
}
.suggestion-box::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.suggestion-item {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #334155;
    transition: all 0.15s;
}

.suggestion-item i {
    font-size: 10px;
    color: #94a3b8;
}

.suggestion-item.active { 
    background: var(--primary); 
    color: white; 
}
.suggestion-item.active i { color: rgba(255,255,255,0.7); }

.suggestion-item:hover:not(.active) { 
    background: #f1f5f9; 
    color: var(--primary); 
}
 .history-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.history-item i { font-size: 10px; opacity: 0.5; }

.menu-toggle:hover { background: var(--main-bg); }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1100;
}

@media (max-width: 991px) {
    body.sidebar-desktop-collapsed .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-desktop-collapsed .main-content {
        margin-left: 0 !important;
    }

    .wrapper {
        display: block !important;
        width: 100%;
        overflow-x: hidden;
    }
    
    .sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height if supported */
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2000;
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
        border-radius: 0;
        border: none;
        padding: 0;
        padding-bottom: constant(safe-area-inset-bottom);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar nav {
        padding-bottom: 120px; /* Extra space at the bottom of menu */
    }

    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 12px 12px 80px 12px !important; /* Extra bottom padding for comfort */
        width: 100%;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .page-header {
        display: none !important;
    }
    
    .tester-container, .crud-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .card { 
        padding: 16px !important; 
        margin-bottom: 0px !important;
        width: 100% !important;
        border-radius: 12px;
    }
    
    .btn-primary {
        width: 100% !important;
        min-height: 54px !important;
        font-size: 16px !important;
    }

    .config-card { position: relative !important; top: 0 !important; }

    /* Fix for any hidden button content */
    .btn-primary i, .btn-primary span {
        display: inline-block !important;
        visibility: visible !important;
    }
}
/* SweetAlert2 Global Compatibility */
.swal2-container {
    z-index: 5000 !important;
}
