/**
 * Custom Styles
 * Multi-Branch Sales & Inventory Management System
 */

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

/* General Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    overflow-x: hidden;
}

/* Sidebar Styles */
body.has-sidebar {
    padding-top: 0;
    padding-left: 250px;
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    z-index: 1040;
    overflow-y: auto;
    transition: all 0.3s;
}

#sidebar .sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#sidebar .sidebar-menu {
    padding: 15px 0;
}

#sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 12px 20px;
    margin: 5px 15px;
    border-radius: 5px;
    transition: all 0.3s;
}

#sidebar .nav-link:hover, 
#sidebar .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.1);
    transform: translateX(5px);
}

#sidebar .nav-link i {
    width: 25px;
    margin-right: 10px;
}

#sidebar .dropdown-menu {
    background: rgba(0,0,0,0.3);
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
}

#sidebar .dropdown-item {
    color: rgba(255,255,255,0.8);
    padding: 10px 30px;
    border-radius: 0;
}

#sidebar .dropdown-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    transform: none;
}

#sidebar .dropdown-divider {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 5px 0;
}

.top-navbar {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    height: 60px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1030;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-navbar .nav-item .nav-link {
    color: #333;
    padding: 0.5rem;
}

.top-navbar .dropdown-menu {
    right: 0;
    left: auto;
}

.main-content {
    margin-top: 60px;
    padding: 20px;
}

.sidebar-toggle {
    display: none;
}

@media (max-width: 991px) {
    body.has-sidebar {
        padding-left: 0;
    }
    
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
    
    .top-navbar {
        left: 0;
    }
    
    .sidebar-toggle {
        display: block;
        background: none;
        border: none;
        color: #333;
        font-size: 1.5rem;
        cursor: pointer;
    }
}

.navbar {
    padding: 0.3rem 0;
    z-index: 1030;
    overflow-x: hidden;
}

.navbar .container-fluid {
    overflow-x: hidden;
}

.navbar-brand {
    font-size: 1rem;
    white-space: nowrap;
}

.navbar-nav {
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.navbar-nav::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.navbar-nav .nav-link {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.navbar-nav .dropdown-menu {
    font-size: 0.9rem;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    border: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-header {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(5px);
}

.dropdown-item i {
    width: 20px;
}

/* Prevent horizontal scroll */
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

html {
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

@media (max-width: 991px) {
    body {
        padding-top: 60px;
    }
    
    .navbar-nav {
        margin-top: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem 0;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
}

@media (min-width: 992px) and (max-width: 1200px) {
    .navbar-nav .nav-link {
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
    }
}

.card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

/* Dashboard Cards */
.stat-card {
    border-left: 4px solid var(--primary-color);
}

/* Tables */
.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* Buttons */
.btn {
    border-radius: 5px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Product Cards for POS */
.product-card {
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    height: 100%;
}

.product-card:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.product-card.selected {
    border-color: var(--success-color);
    background-color: rgba(40, 167, 69, 0.1);
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0.5rem 0;
    min-height: 40px;
}

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

.product-stock {
    font-size: 0.85rem;
    color: #6c757d;
}

.product-stock.low {
    color: var(--danger-color);
    font-weight: 600;
}

/* POS Cart */
.pos-cart {
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    position: sticky;
    top: 80px;
}

.cart-item {
    border-bottom: 1px solid #e9ecef;
    padding: 1rem;
    transition: background-color 0.2s;
}

.cart-item:hover {
    background-color: #f8f9fa;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 0 0 10px 10px;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-control button {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-control input {
    width: 60px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 0.25rem;
}

/* Search Box */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Category Filter */
.category-filter {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.category-filter .btn {
    border-radius: 20px;
    padding: 0.5rem 1rem;
}

/* Badge Styles */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 500;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 0.25em 0.5em;
    font-size: 0.75rem;
}

/* DataTables Custom Styles */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .navbar,
    .btn,
    footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* RTL Support for Arabic */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .navbar-nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .dropdown-menu {
    text-align: right;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .product-card {
        margin-bottom: 1rem;
    }
    
    .pos-cart {
        position: relative;
        top: 0;
        margin-top: 2rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Invoice/Receipt Styles */
.invoice-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.invoice-header {
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.invoice-footer {
    border-top: 2px solid #e9ecef;
    padding-top: 1rem;
    margin-top: 2rem;
    text-align: center;
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-indicator.active {
    background-color: var(--success-color);
}

.status-indicator.inactive {
    background-color: var(--danger-color);
}

.status-indicator.pending {
    background-color: var(--warning-color);
}