/* Base styles */
html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Responsive font sizes */
@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

@media (min-width: 1200px) {
  html {
    font-size: 18px;
  }
}

/* Focus styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Responsive Logo */
.logo-responsive {
  height: 40px;
  width: auto;
  max-width: 200px;
  transition: all 0.3s ease;
}

@media (min-width: 576px) {
  .logo-responsive {
    height: 50px;
    max-width: 250px;
  }
}

@media (min-width: 768px) {
  .logo-responsive {
    height: 60px;
    max-width: 300px;
  }
}

@media (min-width: 992px) {
  .logo-responsive {
    height: 70px;
    max-width: 350px;
  }
}

/* Mobile-first responsive tables */
.table-responsive-mobile {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
  .table-responsive-mobile table {
    min-width: 600px;
  }
  
  .table-responsive-mobile th,
  .table-responsive-mobile td {
    white-space: nowrap;
    padding: 0.5rem;
    font-size: 0.875rem;
  }
}

/* Responsive form controls */
.form-control-mobile {
  font-size: 16px; /* Prevents zoom on iOS */
}

@media (max-width: 767.98px) {
  .form-control-mobile {
    font-size: 16px;
    padding: 0.75rem;
  }
}

/* Responsive buttons */
.btn-mobile {
  min-height: 44px; /* Touch-friendly minimum size */
  padding: 0.75rem 1rem;
}

@media (max-width: 767.98px) {
  .btn-mobile {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .btn-group-mobile .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* Responsive spacing */
.mobile-spacing {
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .mobile-spacing {
    margin-bottom: 1.5rem;
  }
}

/* Responsive text */
.text-responsive {
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .text-responsive {
    font-size: 1rem;
  }
}

/* Card-like containers for mobile */
.mobile-card {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background-color: #fff;
}

@media (min-width: 768px) {
  .mobile-card {
    border: none;
    padding: 0;
    margin-bottom: 0;
    background-color: transparent;
  }
}

/* Responsive flex containers */
.flex-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .flex-mobile {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }
}

/* Responsive sales order input */
.sales-order-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

@media (min-width: 576px) {
  .sales-order-mobile {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }
}

.sales-order-input-mobile {
  width: 100%;
  min-width: 200px;
}

@media (min-width: 576px) {
  .sales-order-input-mobile {
    width: auto;
    flex: 1;
    max-width: 400px;
  }
}

/* Responsive table actions */
.table-actions-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

@media (min-width: 576px) {
  .table-actions-mobile {
    flex-direction: row;
    gap: 0.5rem;
  }
}

/* Loading and transition effects */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

/* Responsive alerts */
.alert-mobile {
  margin: 0.5rem 0;
  padding: 0.75rem;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .alert-mobile {
    margin: 1rem 0;
    padding: 1rem;
    font-size: 1rem;
  }
}

/* ===== MODERN UI DESIGN SYSTEM ===== */

/* Color Palette */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #06b6d4;
  --light-color: #f8fafc;
  --dark-color: #1e293b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
}

/* Modern Card Components - Dark Mode */
.modern-card {
  background: #1e293b;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid #334155;
  overflow: hidden;
  transition: all 0.2s ease;
  color: #f8fafc;
}

.modern-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: #475569;
}

.modern-card-header {
  background: #334155;
  border-bottom: 1px solid #475569;
  padding: 1.5rem;
  font-weight: 600;
  color: #f8fafc;
}

.modern-card-body {
  padding: 1.5rem;
  background: #1e293b;
  color: #f8fafc;
}

.modern-card-footer {
  background: #334155;
  border-top: 1px solid #475569;
  padding: 1rem 1.5rem;
  color: #f8fafc;
}

/* Modern Buttons */
.btn-modern {
  border-radius: var(--radius-md);
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s ease;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-modern:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

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

.btn-modern-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-modern-success {
  background: var(--success-color);
  color: white;
}

.btn-modern-warning {
  background: var(--warning-color);
  color: white;
}

.btn-modern-danger {
  background: var(--danger-color);
  color: white;
}

.btn-modern-outline {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-modern-outline:hover {
  background: var(--primary-color);
  color: white;
}

/* Modern Form Controls - Dark Mode */
.form-control-modern {
  border: 2px solid #475569;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: #334155;
  color: #f8fafc;
}

.form-control-modern:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.2);
  outline: none;
  background: #475569;
}

.form-control-modern::placeholder {
  color: #94a3b8;
}

.form-label-modern {
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 0.5rem;
  display: block;
}

/* Modern Tables - Dark Mode */
.table-modern {
  background: #1e293b;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid #334155;
  color: #f8fafc;
}

.table-modern thead {
  background: #334155;
}

.table-modern thead th {
  border: none;
  padding: 1rem;
  font-weight: 600;
  color: #f8fafc;
  border-bottom: 2px solid #475569;
}

.table-modern tbody td {
  border: none;
  padding: 1rem;
  border-bottom: 1px solid #475569;
  vertical-align: middle;
  color: #f8fafc !important;
  background-color: #1e293b !important;
}

/* Ensure all text elements in table cells are visible */
.table-modern tbody td * {
  color: #f8fafc !important;
}

.table-modern tbody td .text-muted {
  color: #94a3b8 !important;
}

.table-modern tbody td .fw-semibold {
  color: #f8fafc !important;
  font-weight: 600;
}

.table-modern tbody tr:hover {
  background: #334155;
}

.table-modern tbody tr:hover td {
  background: #334155 !important;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

/* Fix code elements in dark mode tables */
.table-modern tbody td code {
  background: #475569 !important;
  color: #f8fafc !important;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
}

.table-modern tbody td .bg-light {
  background: #475569 !important;
  color: #f8fafc !important;
}

/* Modern Page Headers */
.page-header-modern {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  padding: 2rem 0;
  margin-bottom: 2rem;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.page-title-modern {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-subtitle-modern {
  font-size: 1.125rem;
  opacity: 0.9;
  margin: 0.5rem 0 0 0;
}

/* Modern Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.action-btn-edit {
  background: var(--info-color);
  color: white;
}

.action-btn-details {
  background: var(--secondary-color);
  color: white;
}

.action-btn-delete {
  background: var(--danger-color);
  color: white;
}

.action-btn-create {
  background: var(--success-color);
  color: white;
}

/* Modern Status Badges */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge-active {
  background: rgb(16 185 129 / 0.1);
  color: var(--success-color);
}

.status-badge-inactive {
  background: rgb(239 68 68 / 0.1);
  color: var(--danger-color);
}

.status-badge-pending {
  background: rgb(245 158 11 / 0.1);
  color: var(--warning-color);
}

/* Modern Navigation - Mobile Optimized */
.navbar {
  padding: 0.75rem 1rem;
}

.navbar-brand {
  padding: 0.5rem 0;
}

.navbar-toggler {
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.navbar-toggler:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Mobile-optimized nav links */
.navbar-nav .nav-link {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
  margin: 0.25rem 0;
  min-height: 44px; /* Touch-friendly minimum size */
  display: flex;
  align-items: center;
}

.navbar-nav .nav-link:hover {
  color: var(--primary-color);
  background: rgba(37, 99, 235, 0.1);
}

.navbar-nav .nav-link i {
  width: 20px;
  text-align: center;
}

/* Mobile dropdown improvements */
.navbar-nav .dropdown-menu {
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 0.5rem 0;
  margin-top: 0.5rem;
}

.navbar-nav .dropdown-item {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  min-height: 44px; /* Touch-friendly */
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.navbar-nav .dropdown-item:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
}

.navbar-nav .dropdown-item i {
  width: 20px;
  text-align: center;
  margin-right: 0.75rem;
}

/* Mobile-specific improvements */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin-top: 1rem;
    padding: 1rem;
  }
  
  .navbar-nav {
    width: 100%;
  }
  
  .navbar-nav .nav-item {
    width: 100%;
  }
  
  .navbar-nav .nav-link {
    width: 100%;
    justify-content: flex-start;
    padding: 1rem;
    margin: 0.25rem 0;
    border-radius: var(--radius-sm);
  }
  
  .navbar-nav .dropdown-menu {
    position: static !important;
    transform: none !important;
    box-shadow: none;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
    margin: 0.5rem 0 0 0;
    padding: 0.5rem 0;
  }
  
  .navbar-nav .dropdown-item {
    padding: 0.75rem 2rem;
    margin: 0.125rem 0;
  }
  
  /* Login section mobile improvements */
  .navbar-nav .d-flex {
    width: 100%;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .navbar-nav .d-flex .navbar-nav {
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
  }
  
  .navbar-nav .d-flex .nav-link {
    width: auto;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white !important;
    border-radius: var(--radius-md);
    font-weight: 600;
  }
  
  .navbar-nav .d-flex .nav-link:hover {
    background: var(--primary-hover);
    color: white !important;
  }
}

/* Extra small devices */
@media (max-width: 575.98px) {
  .navbar {
    padding: 0.5rem;
  }
  
  .logo-responsive {
    height: 35px;
    max-width: 150px;
  }
  
  .navbar-nav .nav-link {
    font-size: 0.95rem;
    padding: 0.875rem;
  }
  
  .navbar-nav .dropdown-item {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* Modern Alerts - Dark Mode */
.alert-modern {
  border: none;
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
}

.alert-modern-success {
  background: rgb(16 185 129 / 0.2);
  color: #34d399;
  border-left: 4px solid var(--success-color);
}

.alert-modern-danger {
  background: rgb(239 68 68 / 0.2);
  color: #f87171;
  border-left: 4px solid var(--danger-color);
}

.alert-modern-warning {
  background: rgb(245 158 11 / 0.2);
  color: #fbbf24;
  border-left: 4px solid var(--warning-color);
}

.alert-modern-info {
  background: rgb(6 182 212 / 0.2);
  color: #22d3ee;
  border-left: 4px solid var(--info-color);
}

/* Modern Login/Auth Pages */
.auth-container {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 3rem;
  width: 100%;
  max-width: 400px;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--dark-color);
  margin: 0 0 0.5rem 0;
}

.auth-subtitle {
  color: var(--secondary-color);
  margin: 0;
}

/* Modern Empty States */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--secondary-color);
}

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

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--dark-color);
}

.empty-state-description {
  margin-bottom: 2rem;
}

/* Responsive Design Enhancements */
@media (max-width: 767.98px) {
  .page-header-modern {
    padding: 1.5rem 0;
    margin-bottom: 1.5rem;
  }
  
  .page-title-modern {
    font-size: 1.5rem;
  }
  
  .modern-card-body {
    padding: 1rem;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
    justify-content: center;
  }
  
  .auth-card {
    padding: 2rem;
    margin: 1rem;
  }
  
  .table-modern {
    font-size: 0.875rem;
  }
  
  .table-modern thead th,
  .table-modern tbody td {
    padding: 0.75rem 0.5rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --light-color: #1e293b;
    --dark-color: #f8fafc;
    --border-color: #334155;
  }
  
  .modern-card {
    background: #1e293b;
    border-color: var(--border-color);
  }
  
  .table-modern {
    background: #1e293b;
    border-color: var(--border-color);
  }
  
  .form-control-modern {
    background: #1e293b;
    border-color: var(--border-color);
    color: var(--dark-color);
  }
}