/* =========================================================
   Super ERP - Master Enterprise Design System
   Brand: Super ERP (Cheetah 🐆 Speed & Fast Decisions)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --primary-light: #fef3c7;
  --primary-accent: #ff8f00;
  --dark-bg: #0b1120;
  --dark-surface: #1e293b;
  --dark-border: rgba(255, 255, 255, 0.08);
  --light-bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--light-bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* App Container Layout */
.app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* =========================================================
   Sidebar Navigation
   ========================================================= */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--dark-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  object-fit: cover;
  border-radius: 10px;
  border: 1.5px solid var(--primary);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  flex-shrink: 0;
}

.sidebar-brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-brand h1 span {
  color: var(--primary);
}

.sidebar-brand p {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 14px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.nav-item .icon-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-weight: 600;
}

.nav-badge.active {
  background-color: var(--primary);
  color: #000;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #94a3b8;
}

.speed-tag {
  color: var(--primary);
  font-weight: 700;
}

/* =========================================================
   Main Wrapper & Topbar
   ========================================================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--light-bg);
}

.topbar {
  height: 64px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.topbar-title span {
  color: var(--primary-dark);
}

.badge-speed {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.warning {
  background-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* =========================================================
   Content Layout
   ========================================================= */
.content-body {
  padding: 28px;
  flex: 1;
}

/* Brand Hero Card */
.brand-hero-card {
  background: linear-gradient(135deg, #0b1120 0%, #1e293b 80%, #334155 100%);
  border-radius: 14px;
  padding: 24px 30px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-hero-card::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.hero-text h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.hero-text h2 span {
  color: var(--primary);
}

.hero-text p {
  color: #cbd5e1;
  font-size: 0.92rem;
  max-width: 620px;
  line-height: 1.5;
}

.hero-mascot-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  flex-shrink: 0;
}

.hero-mascot-pill img {
  width: 48px;
  height: 48px;
  max-width: 48px;
  max-height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1.5px solid var(--primary);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.hero-mascot-pill .pill-meta h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
}

.hero-mascot-pill .pill-meta span {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

/* Grid Systems */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* Cards */
.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffffff;
}

.card-header h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Info Tables */
.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table tr {
  border-bottom: 1px solid var(--border-light);
}

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

.info-table td {
  padding: 10px 0;
  font-size: 0.86rem;
}

.info-table td.label {
  color: var(--text-muted);
  width: 42%;
  font-weight: 500;
}

.info-table td.value {
  color: var(--text-main);
  font-weight: 700;
  word-break: break-all;
}

/* =========================================================
   Master Data Tabs & Toolbar
   ========================================================= */
.master-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.master-tab-pill {
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 8px;
  background-color: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.15s ease;
}

.master-tab-pill:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.master-tab-pill.active {
  background-color: var(--dark-bg);
  color: var(--primary);
  border-color: var(--dark-bg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.master-header-card {
  margin-bottom: 20px;
  padding: 14px 18px;
}

.master-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.search-form {
  flex: 1;
  max-width: 400px;
}

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

.search-input-group svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-group input {
  width: 100%;
  padding: 8px 36px 8px 38px;
  font-size: 0.86rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  outline: none;
  font-family: inherit;
  transition: all 0.15s ease;
}

.search-input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.clear-search {
  position: absolute;
  right: 12px;
  text-decoration: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================================================
   Data Tables
   ========================================================= */
.master-table-card {
  background-color: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.count-badge {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
}

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

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

.data-table thead tr {
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #fbfcfe;
}

/* Status & Tags */
.status-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  text-transform: capitalize;
}

.status-badge-active {
  background-color: var(--success-bg);
  color: #065f46;
}

.status-badge-warn {
  background-color: var(--primary-light);
  color: #92400e;
}

.status-badge-inactive {
  background-color: #f1f5f9;
  color: #64748b;
}

.status-badge-inhouse {
  background-color: #e0f2fe;
  color: #0369a1;
}

.status-badge-jw {
  background-color: #ede9fe;
  color: #6d28d9;
}

.badge-cat {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-cat.coil { background-color: #fef3c7; color: #92400e; }
.badge-cat.circle { background-color: #d1fae5; color: #065f46; }
.badge-cat.farma { background-color: #ede9fe; color: #5b21b6; }
.badge-cat.finished-goods { background-color: #ffe4e6; color: #9f1239; }

.grade-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-color);
}

.weight-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #047857;
}

/* Action Icons */
.action-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: #e2e8f0;
}

.btn-icon.whatsapp:hover {
  background-color: #d1fae5;
  border-color: #10b981;
}

.btn-icon.email:hover {
  background-color: #dbeafe;
  border-color: #3b82f6;
}

.btn-icon.delete:hover {
  background-color: #fee2e2;
  border-color: #ef4444;
}

/* =========================================================
   Buttons & Alerts
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

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

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

.btn-outline {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f1f5f9;
}

.alert {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.alert-success {
  background-color: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background-color: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* =========================================================
   Modals & Forms
   ========================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(11, 17, 32, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-card {
  background-color: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-card.modal-lg {
  max-width: 820px;
}

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

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background-color: #f8fafc;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.req {
  color: var(--danger);
}

.form-control {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.86rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
  outline: none;
  transition: all 0.15s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Formula Preview Box */
.formula-preview-box {
  margin-top: 18px;
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 16px 20px;
}

.formula-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #92400e;
  font-size: 0.86rem;
}

.formula-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-item label {
  font-size: 0.76rem;
  font-weight: 800;
  color: #78350f;
}

.formula-input {
  background-color: #ffffff;
  font-weight: 800;
  color: #92400e;
}

/* =========================================================
   Footer & Print
   ========================================================= */
.app-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media print {
  .sidebar, .topbar, .master-toolbar, .action-cell, .master-tab-bar, .btn, .alert {
    display: none !important;
  }
  body, .main-wrapper, .content-body {
    background-color: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
  .data-table th, .data-table td {
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
    border: 1px solid #ddd !important;
  }
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .brand-hero-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}
