
/* ==========================================================================
   POS System - Main Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --navbar-height: 60px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;
    --sidebar-hover: #334155;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--body-bg);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--primary-hover);
}

/* --------------------------------------------------------------------------
   Layout - Wrapper
   -------------------------------------------------------------------------- */
.wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: all var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover);
    border-radius: 3px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-brand i {
    font-size: 24px;
    color: var(--primary-color);
}

/* Sidebar Navigation */
.sidebar-nav {
    list-style: none;
    padding: 15px 0;
    margin: 0;
    flex: 1;
}

.sidebar-header-text {
    padding: 15px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sidebar-text);
    opacity: 0.6;
}

.sidebar-item {
    margin: 2px 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--sidebar-text);
    border-radius: 8px;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.sidebar-link i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    text-align: center;
}

.sidebar-link span {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-item.active .sidebar-link {
    background: var(--sidebar-active);
    color: #ffffff;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    padding: 10px;
    background: var(--sidebar-hover);
    border-radius: 8px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 16px;
    margin-right: 12px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    color: var(--sidebar-text);
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
}

/* Top Navbar */
.main-content .navbar {
    height: var(--navbar-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

#sidebarToggle {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
}

#sidebarToggle:hover {
    background: var(--light-color);
}

.user-avatar-sm {
    color: var(--secondary-color);
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Sidebar Toggle States
   -------------------------------------------------------------------------- */
.sidebar-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* --------------------------------------------------------------------------
   Responsive - Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .sidebar-open .sidebar {
        margin-left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    /* Overlay when sidebar is open on mobile */
    .sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stat Cards */
.stat-card {
    padding: 20px;
    border-radius: 12px;
    color: #ffffff;
}

.stat-card.primary { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.stat-card.success { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.stat-card .stat-icon {
    font-size: 40px;
    opacity: 0.3;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    padding: 12px 15px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    padding: 8px 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--transition-speed);
}

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

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-control, .form-select {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-speed);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-label {
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   POS Page Specific
   -------------------------------------------------------------------------- */
.pos-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - var(--navbar-height) - 50px);
}

.pos-products {
    flex: 1;
    overflow-y: auto;
}

.pos-cart {
    width: 400px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Barcode Scanner Input */
.barcode-scanner-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.barcode-scanner-wrapper .form-control {
    padding-left: 45px;
    font-size: 16px;
    height: 50px;
}

.barcode-scanner-wrapper .scanner-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
    font-size: 18px;
}

.barcode-scanner-wrapper .scanner-status {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

.scanner-status.ready {
    color: var(--success-color);
}

.scanner-status.scanning {
    color: var(--warning-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.product-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.product-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.product-card .product-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

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

/* Cart Items */
.cart-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

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

.cart-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: var(--light-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 14px;
}

.cart-item-price {
    color: var(--text-secondary);
    font-size: 13px;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-qty input {
    width: 50px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px;
}

.cart-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--light-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
    padding: 5px 10px;
    font-weight: 500;
    border-radius: 6px;
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.alert {
    border-radius: 10px;
    border: none;
}

/* --------------------------------------------------------------------------
   Modal Customization
   -------------------------------------------------------------------------- */
.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
}

/* --------------------------------------------------------------------------
   Login Page
   -------------------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo i {
    font-size: 48px;
    color: var(--primary-color);
}

.login-logo h1 {
    font-size: 24px;
    margin-top: 10px;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-info { color: var(--info-color) !important; }

.bg-primary-light { background: rgba(79, 70, 229, 0.1); }
.bg-success-light { background: rgba(16, 185, 129, 0.1); }
.bg-danger-light { background: rgba(239, 68, 68, 0.1); }
.bg-warning-light { background: rgba(245, 158, 11, 0.1); }

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */
@media print {
    .sidebar,
    .navbar,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-wrapper {
        padding: 0 !important;
    }
}
