/* Global Styles */
:root {
    --primary-color: #1f6feb;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f5f5f5;
}

/* Landing Page Styles */
.landing-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0d6efd 100%);
}

.brand-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0d6efd 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.brand-content {
    max-width: 500px;
}

.brand-logo {
    max-width: 120px;
    height: auto;
}

.features {
    margin-top: 2rem;
}

.feature-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.feature-item i {
    font-size: 1.5rem;
    margin-right: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

.role-selection {
    max-width: 600px;
    padding: 2rem;
}

.role-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.role-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.role-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.role-card.admin-card:hover {
    border-color: var(--primary-color);
}

.role-card.order-taker-card:hover {
    border-color: var(--success-color);
}

.card-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), #0d6efd);
    color: white;
}

.order-taker-card .card-icon {
    background: linear-gradient(135deg, var(--success-color), #20c997);
}

.role-features {
    margin-top: 1.5rem;
    text-align: left;
}

.role-features span {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.role-features i {
    color: var(--success-color);
    margin-right: 0.5rem;
}

/* Login Page Styles */
.login-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0d6efd 100%);
}

.back-home {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

.back-home:hover {
    color: white;
}

.login-form-container {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.login-form .input-group-text {
    background-color: var(--light-color);
    border-right: none;
}

.login-form .form-control {
    border-left: none;
    padding-left: 0;
}

.login-form .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    max-width: 120px;
    height: auto;
}

.sidebar-menu {
    padding: 1rem 0;
}

.sidebar-item {
    padding: 0.75rem 1.5rem;
    color: var(--secondary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-item:hover, .sidebar-item.active {
    background-color: rgba(31, 111, 235, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.sidebar-item i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.sidebar.collapsed .sidebar-item span {
    display: none;
}

.sidebar.collapsed .sidebar-item i {
    margin-right: 0;
    font-size: 1.3rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
}

.topbar-left {
    display: flex;
    align-items: center;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin-right: 1rem;
    cursor: pointer;
}

.content-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.card-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1.25rem;
    font-weight: 600;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* Tables */
.table-responsive {
    border-radius: 10px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table th {
    background-color: var(--light-color);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    padding: 1rem 0.75rem;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
}

/* Forms */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(31, 111, 235, 0.25);
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0d6efd;
    border-color: #0d6efd;
    transform: translateY(-1px);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #e9ecef;
    border-radius: 10px 10px 0 0;
}

/* Toast */
.toast {
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 1050;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .role-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .content-area {
        padding: 1rem;
    }
    
    .topbar {
        padding: 1rem;
    }
    
    .login-form-container {
        margin: 1rem;
        padding: 1.5rem;
    }
}

/* Utility Classes */
.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }

/* Image Thumbnails */
.img-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}

/* Search and Filters */
.search-box {
    max-width: 300px;
}

.filter-section {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Order Cart */
.order-cart {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.cart-item:last-child {
    border-bottom: none;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.quantity-input {
    width: 50px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.25rem;
}

/* Catalog Grid */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.catalog-item {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.catalog-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.catalog-item img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    margin-bottom: 1rem;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-pending { background-color: #fff3cd; color: #856404; }
.status-approved { background-color: #d1edff; color: #0c63e4; }
.status-delivered { background-color: #d1f2eb; color: #0f5132; }
.status-rejected { background-color: #f8d7da; color: #721c24; }






/* ========== PWA SPECIFIC STYLES ========== */

/* Standalone mode adjustments */
@media all and (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
  }
  
  /* Adjust for notch devices */
  .topbar {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  
  .sidebar {
    padding-top: max(1rem, env(safe-area-inset-top));
    height: 100vh;
    height: 100dvh;
  }
  
  .main-content {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
  }
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #dc3545;
  color: white;
  text-align: center;
  padding: 12px;
  z-index: 9999;
  display: none;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
}

.offline .offline-indicator {
  display: block;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Install prompt styles */
.install-prompt {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  z-index: 1000;
  max-width: 320px;
  border: 1px solid #e9ecef;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.install-prompt-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.install-prompt-icon {
  font-size: 24px;
  color: #007bff;
  margin-right: 12px;
}

.install-prompt-title {
  font-weight: 600;
  margin: 0;
  font-size: 1rem;
}

.install-prompt-body {
  margin-bottom: 16px;
  color: #6c757d;
  font-size: 0.9rem;
}

.install-prompt-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Enhanced mobile styles for PWA */
@media (max-width: 768px) {
  .standalone-mode .topbar {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }
  
  .standalone-mode .sidebar {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }
  
  .install-prompt {
    left: 20px;
    right: 20px;
    max-width: none;
  }
}

/* PWA Loading screen */
.pwa-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
}

.pwa-loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.pwa-loading-text {
  font-size: 1.2rem;
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Network status indicator */
.network-status {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 1000;
  background: #28a745;
  color: white;
  display: none;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.network-status.offline {
  background: #dc3545;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.network-status.online {
  background: #28a745;
}

/* Cache status */
.cache-status {
  position: fixed;
  bottom: 60px;
  left: 20px;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.7rem;
  z-index: 1000;
  background: #17a2b8;
  color: white;
  display: none;
}

/* PWA Debug Info */
.pwa-debug-info {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.9);
  color: #00ff00;
  padding: 15px;
  border-radius: 8px;
  z-index: 10000;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  max-width: 400px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.pwa-debug-info.show {
  display: block;
}

.pwa-debug-title {
  font-weight: bold;
  margin-bottom: 10px;
  color: white;
  border-bottom: 1px solid #333;
  padding-bottom: 5px;
}

.pwa-debug-item {
  margin-bottom: 5px;
  line-height: 1.4;
}

.pwa-debug-item.success {
  color: #00ff00;
}

.pwa-debug-item.error {
  color: #ff4444;
}

.pwa-debug-item.warning {
  color: #ffaa00;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn, .sidebar-item, .role-card {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .sidebar-item {
    padding: 12px 15px;
  }
}

/* Print styles for PWA */
@media print {
  .offline-indicator,
  .install-prompt,
  .network-status,
  .pwa-debug-info {
    display: none !important;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .offline-indicator,
  .install-prompt {
    animation: none;
  }
  
  .pwa-loading-spinner {
    animation-duration: 2s;
  }
}

/* Dark mode support for PWA elements */
@media (prefers-color-scheme: dark) {
  .install-prompt {
    background: #2d3748;
    color: white;
    border-color: #4a5568;
  }
  
  .install-prompt-body {
    color: #cbd5e0;
  }
}