:root {
    --primary-color: #2563eb;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --success-color: #10b981;
    --error-color: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    /* Removed global flex that broke full-screen dashboard */
}

/* Login View specific layout */
.center-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.main-header {
    position: absolute;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.875rem;
    background-color: #e5e7eb;
    color: #6b7280;
}

.status-badge.online {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.offline {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Utilities */
.hidden {
    display: none !important;
    /* Force hide */
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    box-sizing: border-box;
    /* Important for width: 100% */
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.error-msg {
    color: var(--error-color);
    margin-top: 1rem;
    font-size: 0.875rem;
    min-height: 1.25rem;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background-color: #f3f4f6;
    position: fixed;
    /* Ensure it covers everything */
    top: 0;
    left: 0;
}

/* Sidebar */
.sidebar {
    width: 80px;
    background-color: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    gap: 2rem;
    flex-shrink: 0;
}

.logo-small {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.nav-item {
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    position: relative;
    display: flex;
    justify-content: center;
}

.nav-item:hover,
.nav-item.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.nav-item .tooltip {
    position: absolute;
    left: 100%;
    margin-left: 0.5rem;
    background: #1f2937;
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.nav-item:hover .tooltip {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 60px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    font-weight: 600;
    color: var(--text-color);
}

/* POS View Layout */
.view-section {
    flex: 1;
    overflow: hidden;
    padding: 1.5rem;
}

.pos-layout {
    display: flex;
    gap: 1.5rem;
    height: 100%;
}

/* Product Grid */
.product-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.product-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    transition: transform 0.1s, border-color 0.1s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 120px;
}

.product-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    color: var(--primary-color);
    font-weight: 700;
}

.product-stock {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Cart Panel */
.cart-panel {
    width: 350px;
    background: white;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.cart-panel h3 {
    padding: 1rem;
    margin: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.cart-item-price {
    font-size: 0.8rem;
    color: #6b7280;
}

.cart-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: #f3f4f6;
}

.cart-summary {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.summary-row.total {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-color);
}

.btn-checkout {
    width: 100%;
    padding: 1rem;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-checkout:hover {
    background-color: #059669;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 0.5rem;
        justify-content: space-around;
    }

    .nav-item {
        font-size: 1.25rem;
    }

    .nav-item .tooltip {
        display: none;
    }

    .pos-layout {
        flex-direction: column;
    }

    .cart-panel {
        width: 100%;
        height: 40%;
    }
}

/* --- NEW ROBUST UI STYLES --- */

/* Header Actions */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Data Tables */
.table-container {
    background: white;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

.data-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.data-table tr:hover {
    background-color: #fca5a51a;
    /* Subtle hover */
}

/* Actions in Table */
.action-btn {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #d1d5db;
    background: white;
    cursor: pointer;
    margin-right: 0.25rem;
    font-size: 0.85rem;
}

.action-btn.edit {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn.delete {
    color: var(--error-color);
    border-color: var(--error-color);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}

.row {
    display: flex;
    gap: 1rem;
}

.half {
    flex: 1;
}