/* ==========================================================================
   BRICKWOOD Design System & Touch-First Styles
   Samarkand Furniture Materials Workspace
   ========================================================================== */

:root {
  /* Color Palette */
  --primary: #c2410c; /* Deep Terracotta / Brickwood Orange */
  --primary-hover: #9a3412;
  --primary-light: #ffedd5;
  --primary-rgb: 194, 65, 12;

  --secondary: #0f172a; /* Deep Slate Navy */
  --secondary-light: #1e293b;
  --secondary-border: #334155;

  --accent: #d97706; /* Amber */
  --accent-light: #fef3c7;

  --success: #059669; /* Emerald Green */
  --success-light: #d1fae5;
  --success-text: #065f46;

  --danger: #dc2626; /* Crimson Red */
  --danger-light: #fee2e2;
  --danger-text: #991b1b;

  --warning: #d97706;
  --warning-light: #fef3c7;
  --warning-text: #92400e;

  --info: #0284c7;
  --info-light: #e0f2fe;
  --info-text: #075985;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);

  /* Touch Targets & Layout */
  --touch-target-min: 48px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.12), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  --shadow-glow: 0 0 20px rgba(194, 65, 12, 0.25);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* App Shell */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Top Navbar */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--secondary-border);
  color: var(--text-white);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-white);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.4);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  min-height: 40px;
  color: var(--text-light);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
}

.nav-item a:hover,
.nav-item a.active {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.1);
}

.nav-item a.active {
  border-bottom: 2px solid var(--primary);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.role-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-SUPER_ADMIN, .role-ADMIN { background: #fee2e2; color: #991b1b; }
.role-CONSULTANT { background: #e0f2fe; color: #075985; }
.role-CONSTRUCTOR { background: #fef3c7; color: #92400e; }
.role-CUTTER { background: #f3e8ff; color: #6b21a8; }
.role-CASHIER { background: #d1fae5; color: #065f46; }

/* Main Container */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Touch Search Bar */
.search-hero {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: white;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
}

.large-touch-search {
  width: 100%;
  height: 58px;
  background: #ffffff;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 1.25rem 0 3.25rem;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.large-touch-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

/* Category Chips */
.chip-group {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chip-group::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 0.5rem 1rem;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  font-size: 0.88rem;
  transition: var(--transition);
}

.chip:hover, .chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.4);
}

/* Product Cards Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-color);
}

.product-card-img-wrap {
  position: relative;
  width: 100%;
  height: 180px;
  background: #f1f5f9;
  overflow: hidden;
}

.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-card-img {
  transform: scale(1.04);
}

.stock-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.75rem;
  backdrop-filter: blur(8px);
}

.stock-in {
  background: rgba(5, 150, 105, 0.9);
  color: #ffffff;
}

.stock-out {
  background: rgba(220, 38, 38, 0.9);
  color: #ffffff;
}

.product-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-card-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.product-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-article {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: monospace;
  font-weight: 600;
  background: var(--bg-main);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.product-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.product-card-price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--secondary);
  font-family: var(--font-display);
}

/* Touch Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touch-target-min);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

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

.btn-secondary {
  background: var(--secondary);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--secondary-light);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-main);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-lg {
  min-height: 56px;
  padding: 0.85rem 1.75rem;
  font-size: 1.1rem;
}

/* Cards & Panels */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background: var(--bg-main);
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.92rem;
  vertical-align: middle;
}

.table tr:hover td {
  background: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.badge-success { background: var(--success-light); color: var(--success-text); }
.badge-danger { background: var(--danger-light); color: var(--danger-text); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-info { background: var(--info-light); color: var(--info-text); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }

/* Sticky Bottom Tablet Cart Drawer */
.cart-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 2px solid var(--primary);
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
  z-index: 100;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-drawer.active {
  transform: translateY(0);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

.modal-body {
  padding: 1.5rem;
}

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

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

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: var(--touch-target-min);
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.15);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--secondary);
  color: #ffffff;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 420px;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

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

/* Responsive Touch Adjustments */
@media (max-width: 768px) {
  .top-navbar {
    padding: 0 1rem;
    height: 56px;
  }
  .main-content {
    padding: 1rem;
  }
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }
  .product-card-img-wrap {
    height: 130px;
  }
  .product-card-title {
    font-size: 0.88rem;
  }
  .nav-links {
    display: none; /* Accessible via mobile drawer */
  }
}
