:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(34, 197, 94, 0.1), transparent 25%);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

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

.nav-links li {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.details .name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.details .role {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view-section {
    display: none;
    height: 100%;
    flex-direction: column;
    padding: 2rem;
}

.view-section.active {
    display: flex;
}

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

.view-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

/* POS Layout */
.pos-layout {
    display: flex;
    gap: 2rem;
    height: calc(100% - 80px);
}

.products-area {
    flex: 2;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.search-bar {
    position: relative;
    width: 350px;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.search-bar input:focus {
    border-color: var(--primary-color);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.product-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.product-card .icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.product-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.product-card .price {
    color: var(--success);
    font-weight: 700;
}

.product-card .stock {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    display: block;
}

.product-card.low-stock {
    border-color: var(--warning);
}
.product-card.low-stock .stock { color: var(--warning); }

/* Cart */
.cart-area {
    flex: 1.3;
    min-width: 350px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-cart-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.cart-item-info h5 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: var(--success);
    font-weight: 600;
    font-size: 1rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
}

.qty-btn {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.cart-summary {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    font-size: 1.1rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.summary-row.total {
    color: var(--text-main);
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 1rem;
}

.checkout-btn {
    width: 100%;
    padding: 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

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

/* Tables & Stats */
.table-container {
    background: var(--bg-panel);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

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

.data-table th {
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    font-weight: 600;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge.stock-ok { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge.stock-low { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
}
.stat-card h4 { color: var(--text-muted); font-size: 1rem; margin-bottom: 0.5rem; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary-color); }
.stat-card .value.success { color: var(--success); }

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s, opacity 0.3s;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    text-align: center;
}

.modal-body .summary-row.total span:last-child {
    font-size: 2.2rem;
    font-weight: 800;
}

.modal-body input {
    font-size: 1.5rem !important;
    padding: 1rem 1rem 1rem 3.5rem !important;
    height: auto;
}

.input-group {
    margin: 1.5rem 0;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.modal-actions button {
    flex: 1;
}

/* Edit Inputs in Table */
.edit-input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--primary-color);
    color: var(--text-main);
    padding: 0.3rem;
    border-radius: 0.25rem;
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
}

/* Login */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.login-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 3rem 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary-color);
}
.hidden { display: none !important; }

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}
.toast {
    background: var(--bg-dark);
    border-left: 6px solid var(--primary-color);
    color: var(--text-main);
    padding: 1.5rem 2rem;
    border-radius: 0.8rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease forwards, fadeOut 0.5s ease 3s forwards;
    opacity: 0;
    font-weight: 600;
    font-size: 1.4rem;
    min-width: 300px;
    text-align: center;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideIn { 
    from { transform: translateX(100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}
@keyframes fadeOut { 
    from { opacity: 1; } 
    to { opacity: 0; display: none; } 
}
