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

:root {
    --bg-dark: #0a0b10;
    --bg-card: rgba(18, 20, 32, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-focus: rgba(147, 51, 234, 0.4);
    --primary: #9333ea;
    --primary-glow: rgba(147, 51, 234, 0.35);
    --secondary: #3b82f6;
    --secondary-glow: rgba(59, 130, 246, 0.2);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-white: #ffffff;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(147, 51, 234, 0.12) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(59, 130, 246, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-font {
    font-family: 'Outfit', sans-serif;
}

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

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Inputs and Forms */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-white);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(31, 41, 55, 0.8);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text-white);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(147, 51, 234, 0.5);
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

/* Auth / Login Page Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

/* Dashboard App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar navigation */
.sidebar {
    width: 260px;
    background: rgba(10, 11, 16, 0.85);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-white);
    box-shadow: 0 4px 10px var(--primary-glow);
}

.brand-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-white);
    letter-spacing: -0.02em;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-glow), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(147, 51, 234, 0.2);
    color: var(--text-white);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-glass);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f472b6, #9333ea);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-white);
}

.user-info {
    flex-grow: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-white);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
}

.logout-btn:hover {
    transform: scale(1.1);
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 40px;
}

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

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-white);
}

/* Dashboard Grid Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-white);
}

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

.bg-primary-glow { background: var(--primary-glow); color: #c084fc; }
.bg-secondary-glow { background: var(--secondary-glow); color: #60a5fa; }
.bg-success-glow { background: var(--success-glow); color: #34d399; }
.bg-danger-glow { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.bg-warning-glow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-online { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-offline { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-maintenance { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-inactive { background: rgba(156, 163, 175, 0.15); color: #d1d5db; border: 1px solid rgba(156, 163, 175, 0.3); }

/* Tables styling */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.95rem;
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table-row-clickable {
    cursor: pointer;
}

/* Pulsing indicators */
.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.pulse-green { background-color: var(--success); box-shadow: 0 0 0 0 var(--success-glow); animation: pulseGreen 2s infinite; }
.pulse-red { background-color: var(--danger); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); animation: pulseRed 2s infinite; }

@keyframes pulseGreen {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseRed {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Tabs container and view toggle */
.tab-view {
    display: none;
}

.tab-view.active-view {
    display: block;
}

/* Details Page (Machine View) */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.detail-info-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-glass);
    padding-bottom: 10px;
}

.detail-info-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-info-val {
    font-weight: 500;
    color: var(--text-white);
}

.tab-nav-row {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 1px;
    margin-bottom: 20px;
}

.tab-nav-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab-nav-btn:hover, .tab-nav-btn.active {
    color: var(--text-white);
}

.tab-nav-btn.active {
    border-bottom-color: var(--primary);
}

.detail-tab-content {
    display: none;
}

.detail-tab-content.active {
    display: block;
}

/* Vending Machine Simulator Frame (240x360 screen and cabinet) */
.simulator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.vending-cabinet {
    width: 320px;
    background: #1e1b29;
    border: 4px solid #110f18;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-self: center;
    border-top: 10px solid #2e2a3d;
}

.vending-header {
    text-align: center;
    font-weight: 800;
    color: #e9d5ff;
    letter-spacing: 0.1em;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
    border-bottom: 2px solid #110f18;
    padding-bottom: 10px;
}

/* The actual 240x360 screen representing the hardware screen */
.vending-screen-wrapper {
    width: 240px;
    height: 360px;
    background: #000;
    border-radius: 12px;
    border: 6px solid #2d2640;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
}

.vending-screen {
    width: 100%;
    height: 100%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    color: #38bdf8;
    font-family: monospace;
    font-size: 0.8rem;
    text-align: center;
}

.screen-title {
    font-size: 0.9rem;
    font-weight: bold;
    color: #f0abfc;
    margin-bottom: 5px;
}

.screen-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.qr-code-display {
    width: 130px;
    height: 130px;
    background: white;
    border: 4px solid #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code-display img {
    width: 100%;
    height: 100%;
}

.screen-footer {
    width: 100%;
    border-top: 1px dashed rgba(56, 189, 248, 0.3);
    padding-top: 6px;
    font-size: 0.75rem;
    color: #93c5fd;
}

.timer-highlight {
    font-weight: bold;
    color: #fb7185;
    font-size: 1.1rem;
}

/* Vending Selection Panel */
.vending-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    background: #110f18;
    border-radius: 12px;
}

.keypad-btn {
    height: 40px;
    background: #2e2a3d;
    border: 1px solid #3d3751;
    color: #e9d5ff;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.keypad-btn:hover {
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.keypad-btn.active-key {
    background: var(--secondary);
    box-shadow: 0 0 10px var(--secondary-glow);
}

/* Modal Popup standard */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.4rem;
    color: var(--text-white);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Alert system styles */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    padding: 16px 24px;
    border-radius: 10px;
    color: var(--text-white);
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
    transform: translateY(100px);
    opacity: 0;
    animation: slideIn 0.3s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-success { background: var(--success); }
.toast-danger { background: var(--danger); }
.toast-info { background: var(--secondary); }

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

/* Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.flex-row { display: flex; gap: 10px; }
.flex-between { justify-content: space-between; align-items: center; }
.cursor-pointer { cursor: pointer; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
