/* ==========================================================================
   Design System Variables
   ========================================================================== */
:root {
  /* Dark Theme Default */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: rgba(30, 41, 59, 0.7);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --brand-primary: #3b82f6;
  --brand-primary-hover: #2563eb;
  
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;

  --border-color: #334155;
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-bg: rgba(15, 23, 42, 0.6);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
}

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

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

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.text-secondary { color: var(--text-secondary); }

/* ==========================================================================
   Components
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand-primary);
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-outline:hover {
  background-color: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn-icon-only {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-icon-only:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}

.toast {
  min-width: 300px;
  max-width: 400px;
  padding: 1rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  border-left: 4px solid var(--brand-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success { border-left-color: var(--accent-success); }
.toast.error { border-left-color: var(--accent-danger); }
.toast.warning { border-left-color: var(--accent-warning); }

.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--accent-success); }
.toast.error .toast-icon { color: var(--accent-danger); }
.toast.warning .toast-icon { color: var(--accent-warning); }
.toast.info .toast-icon { color: var(--brand-primary); }

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toast-close {
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.toast-close:hover { color: var(--text-primary); }

.toast.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

/* ==========================================================================
   Views: Login
   ========================================================================== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
}

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

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--brand-primary);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}

.login-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Views: Dashboard Layout
   ========================================================================== */
.dashboard-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
}

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

.nav-item.active {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--brand-primary);
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow: hidden;
}

.topbar {
  height: 4rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background-color: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.content-area {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* ==========================================================================
   Dashboard Components: Stats & Cards
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: transform var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.5rem;
  color: var(--text-primary);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.green { background-color: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-icon.yellow { background-color: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-icon.red { background-color: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* ==========================================================================
   Dashboard Components: Table
   ========================================================================== */
.table-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.02);
}

.table-actions {
  display: flex;
  gap: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.875rem;
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: var(--bg-tertiary);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-new { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-assigned { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-waiting { background-color: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-progress { background-color: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.badge-done { background-color: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-canceled { background-color: rgba(239, 68, 68, 0.15); color: #f87171; }

/* Empty state */
.empty-state {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg {
  margin: 0 auto 1rem;
  opacity: 0.5;
}

/* Spinner */
.spinner {
  animation: spin 1s linear infinite;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: var(--radius-lg);
}

/* Loader Base */
.loader-xs { width: 1rem; height: 1rem; }
.loader-md { width: 2rem; height: 2rem; }
.loader-lg { width: 3rem; height: 3rem; }

/* Create Order Modal Base Structure (hidden by default) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}
