/* ============================================
   MODERN UI DESIGN SYSTEM - BSM Application
   ============================================ */

/* CSS Variables for Design System */
:root {
  /* Color Palette */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary-color: #64748b;
  --accent-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  
  /* Neutral Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  
  /* Sidebar */
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --sidebar-width: 260px;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Shadows */
  --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);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */

.sidenav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0f172a 100%);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
}

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

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

.sidenav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.sidenav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Header */
.sidenav::before {
  content: 'BSM';
  display: block;
  padding: var(--spacing-xl) var(--spacing-lg);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--bg-primary);
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: var(--spacing-md);
}

/* Navigation Links */
.sidenav a {
  display: flex;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-xs) var(--spacing-md);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  position: relative;
}

.sidenav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--primary-color);
  border-radius: 0 2px 2px 0;
  transition: height var(--transition-base);
}

.sidenav a:hover {
  background-color: var(--sidebar-hover);
  color: var(--bg-primary);
  transform: translateX(4px);
}

.sidenav a:hover::before {
  height: 60%;
}

.sidenav a:active {
  background-color: var(--sidebar-active);
  color: var(--bg-primary);
}

/* Active Link State */
.sidenav a.active {
  background-color: var(--sidebar-active);
  color: var(--bg-primary);
  font-weight: 600;
}

.sidenav a.active::before {
  height: 80%;
}

/* Settings Button at Bottom */
.sidenav-settings {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.sidenav a.settings-link {
  margin: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

/* Settings Modal */
.settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.settings-modal.open {
  display: flex;
}

.settings-modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: fadeIn var(--transition-slow) ease-out;
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--border-color);
}

.settings-modal-header h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.settings-close {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.settings-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.settings-section {
  margin-bottom: var(--spacing-xl);
}

.settings-section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.settings-option:hover {
  background: var(--bg-tertiary);
}

.settings-option-label {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: 500;
}

.theme-selector {
  display: flex;
  gap: var(--spacing-sm);
}

.theme-option {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.theme-option:hover {
  border-color: var(--primary-color);
  background: var(--bg-tertiary);
}

.theme-option.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: var(--bg-primary);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1e293b;
  --bg-secondary: #0f172a;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-hover: #475569;
}

[data-theme="dark"] .card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .sidenav {
  background: linear-gradient(180deg, #0f172a 0%, #020617 100%);
}

/* Light Theme (default) */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main {
  margin-left: var(--sidebar-width);
  padding: var(--spacing-xl);
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

/* Page Header */
.page-header {
  margin-bottom: var(--spacing-2xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.page-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
}

@media screen and (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-orders-list {
  max-height: 400px;
  overflow-y: auto;
}

.dashboard-order-item {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-fast);
}

.dashboard-order-item:hover {
  background-color: var(--bg-tertiary);
}

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

/* ============================================
   BUTTONS
   ============================================ */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--bg-primary);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
  margin-right: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  position: relative;
  overflow: hidden;
}

button::before,
.button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:hover::before,
.button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover,
.button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
}

button:active,
.button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button:focus,
.button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Button Variants */
button.secondary,
.button.secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

button.danger,
.button.danger {
  background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
}

button.danger:hover,
.button.danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, var(--danger-color) 100%);
}

button.success,
.button.success {
  background: linear-gradient(135deg, var(--accent-color) 0%, #059669 100%);
}

button.success:hover,
.button.success:hover {
  background: linear-gradient(135deg, #059669 0%, var(--accent-color) 100%);
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  margin-right: var(--spacing-md);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: var(--spacing-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  margin-bottom: var(--spacing-md);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-hover);
}

/* Input Variants */
.input_no_border {
  border: none !important;
  background: transparent !important;
  padding: var(--spacing-sm) !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.input_no_border:focus {
  background: var(--bg-tertiary) !important;
  border-radius: var(--radius-sm) !important;
}

.input_2px_border {
  border: 2px solid var(--border-color) !important;
  padding: var(--spacing-md) !important;
  font-size: var(--font-size-base) !important;
  border-radius: var(--radius-md) !important;
  margin-right: var(--spacing-md) !important;
  margin-bottom: var(--spacing-md) !important;
}

/* Form Groups */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-row {
  display: flex;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.form-row > * {
  flex: 1;
}

/* Form Sections */
.form-section {
  margin-bottom: var(--spacing-2xl);
  padding-bottom: var(--spacing-xl);
  border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: var(--spacing-xl);
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--border-color);
}

/* Form Grid Layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-lg);
  margin-top: var(--spacing-md);
}

@media screen and (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (min-width: 1200px) {
  .form-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Form Actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-xl);
  border-top: 2px solid var(--border-color);
}

/* Checkbox */
.chkbox {
  width: 20px;
  height: 20px;
  margin-top: var(--spacing-sm);
  cursor: pointer;
  accent-color: var(--primary-color);
}

/* ============================================
   TABLES
   ============================================ */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-xl);
}

table th {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: var(--bg-primary);
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-align: left;
  padding: var(--spacing-md) var(--spacing-lg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

table td {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

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

table tr:hover {
  background-color: var(--bg-tertiary);
  transition: background-color var(--transition-fast);
}

table tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

table tr:nth-child(even):hover {
  background-color: var(--bg-tertiary);
}

/* Table Cell Inputs */
table td input.input_no_border {
  width: 100%;
  padding: var(--spacing-sm);
  font-size: var(--font-size-base);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

table td input.input_no_border:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

table td input.input_no_border:focus {
  background: var(--bg-primary);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

table td label.tot {
  display: block;
  padding: var(--spacing-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  white-space: nowrap;
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */

.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-xl);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--border-color);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.space {
  margin-top: var(--spacing-lg);
}

.desc {
  font-weight: 600;
  font-style: italic;
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

/* ============================================
   DROPDOWN MENU
   ============================================ */

.dropdown {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  margin-top: var(--spacing-xs);
}

.dropdown-option {
  padding: var(--spacing-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  border-bottom: 1px solid var(--border-color);
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover {
  background-color: var(--bg-tertiary);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media screen and (max-width: 768px) {
  .sidenav {
    transform: translateX(-100%);
  }
  
  .sidenav.open {
    transform: translateX(0);
  }
  
  .main {
    margin-left: 0;
    padding: var(--spacing-md);
  }
  
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  table {
    font-size: var(--font-size-sm);
  }
  
  table th,
  table td {
    padding: var(--spacing-sm);
  }
}

@media screen and (max-height: 450px) {
  .sidenav {
    padding-top: var(--spacing-md);
  }
  
  .sidenav a {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.fade-in {
  animation: fadeIn var(--transition-slow) ease-out;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

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

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