:root {
    --bg-card: rgba(255, 255, 255, 0.2);
    /* 80% transparency */
    --primary: #5c5cff;
    /* Bright purple/blue like the image */
    --primary-hover: #4a4ae6;
    --text-main: #1e293b;
    --text-muted: #475569;
    --border: rgba(255, 255, 255, 0.4);
    --shadow-light: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --shadow-heavy: 0 16px 40px 0 rgba(31, 38, 135, 0.25);
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    /* Menggunakan gambar corak dari user */
    background-color: #f8faff;
    background-image: url('bg-corak.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-light);
}

/* Views */
.view {
    display: none;
    min-height: 100vh;
}

.view.active {
    display: flex;
}

/* Login - Split Panel */
#loginView {
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-split-card {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 900px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: none;
    min-height: 550px;
}

.login-left {
    flex: 1;
    padding: 3rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-header h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-right {
    flex: 1;
    background: linear-gradient(135deg, #eef2ff 0%, #ffffff 100%);
    padding: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.login-right::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(92, 92, 255, 0.05), transparent 60%);
}

.info-card {
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
    text-align: center;
    max-width: 320px;
    z-index: 1;
}

.info-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
    background: #f5f3ff;
    width: 70px;
    height: 70px;
    line-height: 70px;
    border-radius: 16px;
    display: inline-block;
}

.info-card h3 {
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.info-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.login-footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
}

.btn-block {
    border-radius: 8px;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    margin-top: 1rem;
    display: block;
}

/* Forms */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(92, 92, 255, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -1px rgba(0, 0, 0, 0.15);
}

.btn.sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn.primary {
    background-color: var(--primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-main);
}

.btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.9);
}

.btn.danger {
    background-color: rgba(254, 226, 226, 0.8);
    color: var(--danger);
}

.btn.danger:hover {
    background-color: rgba(254, 202, 202, 0.9);
}

.error-text {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 1rem;
    text-align: center;
}

/* Dashboard Floating Layout */
#dashboardView {
    display: none;
    padding: 1.5rem;
    gap: 1.5rem;
}

#dashboardView.active {
    display: flex;
}

.sidebar {
    width: 260px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 1.5rem;
    height: calc(100vh - 3rem);
}

.brand {
    padding: 1.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
}

.nav-links {
    list-style: none;
    flex: 1;
    padding: 1rem;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links li a {
    display: block;
    padding: 0.875rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 10px;
    font-weight: 500;
}

.nav-links li a:hover,
.nav-links li a.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/* Topbar / Header Floating */
.topbar {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px;
}

.topbar h2 {
    font-weight: 700;
    color: var(--text-main);
}

.profile-menu {
    position: relative;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

.profile-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 200px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-heavy);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
}

.dropdown.active {
    display: flex;
    animation: dropdownIn 0.2s ease-out forwards;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown a {
    padding: 0.875rem 1.25rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.dropdown a:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown a.text-danger {
    color: var(--danger);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Stats Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 100%;
    overflow: hidden;
}

.panel.active {
    display: flex;
}

/* Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.card {
    padding: 1.5rem;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.ready {
    background: rgba(5, 150, 105, 0.15);
    color: var(--success);
}

.badge.disconnected {
    background: rgba(220, 38, 38, 0.15);
    color: var(--danger);
}

.badge.initializing,
.badge.qr {
    background: rgba(217, 119, 6, 0.15);
    color: var(--warning);
}

.card-body p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    word-break: break-all;
}

.card-body strong {
    color: var(--text-main);
}

.card-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Tables */
.table-container {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    overflow-x: auto;
    padding: 1px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1.25rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Icon Buttons */
.icon-btn {
    padding: 0.5rem !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px !important;
    margin-right: 0.25rem;
}
.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-heavy);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-main);
    font-weight: 700;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

#qrcode-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    display: inline-block;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Topbar Z-Index Fix */
.topbar {
    position: relative;
    z-index: 1000;
}
.dropdown {
    z-index: 2000;
}
.panel {
    position: relative;
    z-index: 1;
}

/* Fix Table Width on Mobile */
.data-table {
    min-width: 600px;
}
.data-table th,
.data-table td {
    white-space: nowrap;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 8888;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .mobile-only { display: inline-flex !important; }
    
    /* Login */
    .login-split-card {
        flex-direction: column;
        min-height: auto;
    }
    .login-left, .login-right {
        padding: 2rem;
    }
    .login-right {
        display: none;
    }
    
    /* Dashboard */
    #dashboardView {
        padding: 1rem;
    }
    
    /* Mobile Sidebar Drawer */
    .sidebar-overlay.mobile-open {
        display: block;
    }
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        border: none;
        border-right: 1px solid var(--border);
    }
    .sidebar.mobile-open {
        left: 0;
    }
    .nav-links {
        display: block;
    }
    .nav-links li {
        margin-bottom: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
    
    .data-table th, .data-table td {
        padding: 1rem 0.75rem;
    }
}

/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #ffffff;
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(-100%);
    opacity: 0;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    min-width: 250px;
}

.toast.toast-error {
    border-left-color: var(--danger);
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-hiding {
    animation: toastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* =========================================
   DARK THEME OVERRIDE FOR DASHBOARD 
   (High Contrast for Colorful Backgrounds)
   ========================================= */
#dashboardView .glass {
    background: rgba(15, 23, 42, 0.6) !important; /* Dark glass */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4) !important;
}

#dashboardView {
    color: #f8fafc;
}

#dashboardView h2, #dashboardView h3 {
    color: #ffffff;
}

#dashboardView .brand {
    color: #60a5fa !important; /* Bright blue */
}

#dashboardView .nav-links a {
    color: #cbd5e1;
}

#dashboardView .nav-links a:hover, 
#dashboardView .nav-links a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

#dashboardView .stat-label {
    color: #94a3b8 !important;
}

#dashboardView .stat-value {
    color: #38bdf8 !important; /* Bright light blue */
}

#dashboardView .data-table th {
    color: #94a3b8;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

#dashboardView .data-table td {
    color: #f1f5f9;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}

#dashboardView .btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#dashboardView .btn.secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

#usernameDisplay {
    color: #f8fafc;
}

#dashboardView .profile-btn {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #f8fafc !important;
}

#dashboardView .profile-btn:hover {
    background: rgba(30, 41, 59, 0.8) !important;
}

#dashboardView .profile-icon {
    background: rgba(56, 189, 248, 0.2) !important;
    color: #38bdf8 !important;
    font-weight: 700;
}

#dashboardView .sidebar-footer p {
    color: #94a3b8 !important;
}

/* =========================================
   DARK THEME OVERRIDE FOR LOGIN
   (80% Transparency Dark Glass)
   ========================================= */
.login-split-card {
    background: rgba(15, 23, 42, 0.8) !important; /* 80% opaque dark glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.login-left {
    background: transparent !important;
}

.login-right {
    background: transparent !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.login-right::before {
    display: none; /* Hilangkan gradient radial bawaan */
}

.login-header h2 {
    color: #ffffff !important;
}

.login-header p {
    color: #cbd5e1 !important;
}

#loginView .input-group label {
    color: #cbd5e1 !important;
}

#loginView .input-group input {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

#loginView .input-group input::placeholder {
    color: #64748b !important;
}

#loginView .input-group input:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.2) !important;
}

.login-footer {
    color: #94a3b8 !important;
}

.info-card {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.info-card h3 {
    color: #ffffff !important;
}

.info-card p {
    color: #cbd5e1 !important;
}

.info-icon {
    background: rgba(56, 189, 248, 0.2) !important;
    color: #38bdf8 !important;
}