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

:root, [theme="light"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --background: #f1f5f9;
    --background-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: rgba(255, 255, 255, 0.95);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --danger: #ef4444;
    --success: #10b981;
    --glass-blur: blur(12px);
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[theme="dark"] {
    --background: #0f172a;
    --background-gradient: linear-gradient(135deg, var(--background) 0%, #1e1b4b 100%);
    --surface: rgba(30, 41, 59, 0.7);
    --surface-hover: rgba(30, 41, 59, 0.9);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--background-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 var(--shadow-color);
}

.glass-card {
    padding: 24px;
    border-radius: 16px;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    background: var(--surface-hover);
}

/* Layout */
.sidebar {
    width: 280px;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 80px;
    padding: 32px 12px;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-logo span, .sidebar.collapsed .sidebar-logo img {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-link span {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .nav-link i {
    font-size: 20px;
    margin: 0 auto;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 0;
}

.nav-link:hover, .nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    transform: translateX(5px);
}

.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Typography & Headings */
h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
}

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

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #f87171);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, var(--danger));
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #34d399);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

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

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
}

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

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* POS Specific */
.pos-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.product-item {
    cursor: pointer;
    text-align: center;
}

.product-item h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.product-item p {
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
}

.pos-products-panel, .cart-panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
}

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

.cart-summary {
    border-top: 2px dashed var(--border);
    padding-top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 16px;
}

.summary-row.total {
    font-size: 24px;
    font-weight: 700;
    color: var(--success);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
    padding: 0;
}
.page-item .page-link, .page-item span {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}
.page-item.active span, .page-item.active .page-link {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.page-item.disabled span {
    opacity: 0.5;
}
.page-link:hover {
    background: var(--primary-hover);
    color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .pos-grid {
        grid-template-columns: 1fr !important;
    }
    .main-content {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        width: 280px !important;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        padding: 16px;
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header > div {
        width: 100%;
    }
    
    .page-header form {
        width: 100%;
    }
    
    .page-header input {
        width: 100% !important;
    }
    
    /* Make all pos-grids stack regardless of inline styles */
    .pos-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .pos-grid.pos-main-layout {
        display: flex;
        flex-direction: column-reverse; /* Put cart on top for mobile */
    }
    
    .pos-products-panel, .cart-panel {
        height: auto;
    }
    
    .pos-products-panel {
        max-height: 50vh;
    }
    
    .cart-panel {
        max-height: 70vh;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* Sidebar Overlay */
#sidebarOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
    #sidebarOverlay.active {
        display: block;
    }
}
