/* ==========================================================================
   Optima ERP & Custom Software Platform — Demo Stylesheet
   TechOrbit Showcase Demo (100% Mobile Responsive)
   ========================================================================== */

:root {
  --erp-primary: #3B82F6;
  --erp-primary-hover: #2563EB;
  --erp-primary-subtle: #EFF6FF;
  --erp-bg: #0F172A;
  --erp-surface: #1E293B;
  --erp-surface-card: #1E293B;
  --erp-border: #334155;
  --erp-text: #F8FAFC;
  --erp-text-muted: #94A3B8;
  --erp-success: #10B981;
  --erp-warning: #F59E0B;
  --erp-danger: #EF4444;
  --erp-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --erp-radius: 10px;
}

[data-theme="light"] {
  --erp-bg: #F1F5F9;
  --erp-surface: #FFFFFF;
  --erp-surface-card: #FFFFFF;
  --erp-border: #E2E8F0;
  --erp-text: #0F172A;
  --erp-text-muted: #64748B;
  --erp-primary-subtle: #DBEAFE;
}

[data-theme="purple"] {
  --erp-primary: #8B5CF6;
  --erp-primary-hover: #7C3AED;
  --erp-primary-subtle: #EDE9FE;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--erp-font-sans);
  background-color: var(--erp-bg);
  color: var(--erp-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================= Top Demo Bar ================= */
.demo-top-bar {
  background: #020617;
  color: #E2E8F0;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.825rem;
  border-bottom: 1px solid #1E293B;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.demo-top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.demo-badge-live {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
  animation: pulse-badge 2s infinite ease-in-out;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.97); }
}

.demo-top-bar-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-pill-btn {
  background: #1E293B;
  border: 1px solid #334155;
  color: #CBD5E1;
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-pill-btn:hover, .theme-pill-btn.active {
  background: var(--erp-primary);
  border-color: var(--erp-primary);
  color: #FFFFFF;
}

.btn-return-techorbit {
  background: var(--erp-primary);
  color: #FFFFFF;
  text-decoration: none;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s;
  font-size: 0.75rem;
  border: none;
  cursor: pointer;
}

.btn-return-techorbit:hover {
  filter: brightness(1.1);
}

/* ================= App Layout ================= */
.app-container {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 45px);
}

/* Sidebar */
.erp-sidebar {
  width: 260px;
  background-color: var(--erp-surface);
  border-right: 1px solid var(--erp-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--erp-border);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--erp-primary), #6366F1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #FFF;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--erp-text-muted);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--erp-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-link:hover, .nav-link.active {
  background: var(--erp-primary-subtle);
  color: var(--erp-primary);
  font-weight: 600;
}

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

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

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--erp-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #FFF;
  font-size: 0.85rem;
}

/* Main Content Area */
.erp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--erp-bg);
}

.erp-top-header {
  height: 64px;
  background: var(--erp-surface);
  border-bottom: 1px solid var(--erp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--erp-border);
  color: var(--erp-text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
}

.header-search {
  display: flex;
  align-items: center;
  background: var(--erp-bg);
  border: 1px solid var(--erp-border);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  width: 320px;
  gap: 0.5rem;
}

.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--erp-text);
  font-size: 0.875rem;
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-erp-primary {
  background: var(--erp-primary);
  color: #FFF;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-erp-primary:hover {
  background: var(--erp-primary-hover);
  transform: translateY(-1px);
}

.btn-erp-outline {
  background: transparent;
  border: 1px solid var(--erp-border);
  color: var(--erp-text);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-erp-outline:hover {
  background: var(--erp-surface);
  border-color: var(--erp-primary);
  color: var(--erp-primary);
}

/* Dashboard Body */
.erp-content {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.kpi-card {
  background: var(--erp-surface-card);
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--erp-primary);
}

.kpi-info h5 {
  font-size: 0.8rem;
  color: var(--erp-text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--erp-text);
  margin-bottom: 0.2rem;
}

.kpi-trend {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.trend-up { color: var(--erp-success); }
.trend-down { color: var(--erp-danger); }

.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: rgba(59, 130, 246, 0.12);
  color: var(--erp-primary);
}

/* ERP Sections Grid */
.dashboard-columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.erp-card {
  background: var(--erp-surface-card);
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

.erp-card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.erp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.erp-table th {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--erp-text-muted);
  border-bottom: 1px solid var(--erp-border);
}

.erp-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--erp-border);
}

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

.erp-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-in-stock { background: rgba(16, 185, 129, 0.15); color: var(--erp-success); }
.status-low-stock { background: rgba(245, 158, 11, 0.15); color: var(--erp-warning); }
.status-reorder { background: rgba(239, 68, 68, 0.15); color: var(--erp-danger); }
.status-progress { background: rgba(59, 130, 246, 0.15); color: var(--erp-primary); }

/* Batch Progress Bars */
.batch-list {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.batch-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.batch-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}

.progress-bar-bg {
  height: 8px;
  background: var(--erp-border);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--erp-primary), #10B981);
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* Modal */
.erp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.erp-modal-backdrop.open {
  display: flex;
}

.erp-modal-content {
  background: var(--erp-surface);
  border: 1px solid var(--erp-border);
  border-radius: var(--erp-radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.erp-modal-body {
  padding: 1.25rem;
}

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

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--erp-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

/* Toast */
.erp-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--erp-surface);
  border: 1px solid var(--erp-border);
  color: var(--erp-text);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 2100;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.erp-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ================= Responsive Rules ================= */
@media (max-width: 992px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
  
  .erp-sidebar {
    position: fixed;
    top: 45px;
    bottom: 0;
    left: 0;
    z-index: 999;
    transform: translateX(-100%);
  }
  
  .erp-sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-menu-toggle {
    display: inline-flex;
  }

  .header-search {
    width: 200px;
  }
}

@media (max-width: 640px) {
  .demo-top-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .demo-top-bar-controls {
    width: 100%;
    justify-content: space-between;
  }
  .erp-top-header {
    padding: 0 1rem;
  }
  .header-search {
    display: none;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
