/* =============================================
   Matra Labs – Custom Stylesheet
   Corporate Theme: Green & Black (Oil & Gas)
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────── */
:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #43a047;
  --accent: #66bb6a;
  --surface-dark: #055035;
  --surface-mid: #055035;
  --surface-light: #2c2c2c;
  --text-light: #e8f5e9;
  --text-muted: #a5d6a7;
  --sidebar-width: 240px;
  --topbar-height: 58px;
  --border-radius: 8px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  --transition: 0.25s ease;
}

/* ── Reset & Base ──────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background: #f0f2f5;
  color: #2c2c2c;
  height: 100%;
  font-size: 14.5px;
  /* Simulates ~90% zoom of base 16px */
  line-height: 1.45;
}

/* ── Sidebar ───────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #055035;
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform var(--transition);
  overflow-y: auto;
}

#sidebar .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--surface-light);
  text-decoration: none;
}

#sidebar .sidebar-brand .brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
}

#sidebar .sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
}

#sidebar .sidebar-brand .brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

#sidebar .sidebar-brand .brand-sub {
  font-size: 0.65rem;
  color: #fff;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

#sidebar .sidebar-section {
  padding: 16px 20px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1.8px;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  border-radius: 0 8px 8px 0;
  margin: 1px 8px 1px 0;
}

#sidebar .nav-link:hover {
  background: rgba(46, 125, 50, 0.12);
  color: var(--accent);
  border-left-color: var(--primary-light);
}

#sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(46, 125, 50, 0.25), rgba(46, 125, 50, 0.05));
  color: #fff;
  border-left-color: var(--accent);
}

#sidebar .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

#sidebar .sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--surface-light);
}

#sidebar .sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#sidebar .sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

#sidebar .sidebar-footer .user-details .user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

#sidebar .sidebar-footer .user-details .user-role {
  font-size: 0.68rem;
  color: #fff;
  text-transform: capitalize;
}

/* ── Topbar ────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  z-index: 1040;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  transition: left var(--transition);
}

#topbar .topbar-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #6b7280;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: none;
  line-height: 1;
}

#topbar .topbar-toggle:hover {
  background: #f3f4f6;
  color: var(--primary);
}

#topbar .topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  flex: 1;
}

#topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#topbar .topbar-user {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: #374151;
}

#topbar .topbar-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
}

.btn-logout {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── Main Content ──────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 20px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left var(--transition);
}

/* ── Cards ─────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 18px;
  border-left: 4px solid var(--primary);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.stat-card .stat-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.green {
  background: #e8f5e9;
  color: var(--primary);
}

.stat-card .stat-icon.teal {
  background: #e0f7fa;
  color: #00838f;
}

.stat-card .stat-icon.amber {
  background: #fff8e1;
  color: #f57f17;
}

.stat-card .stat-icon.indigo {
  background: #e8eaf6;
  color: #3949ab;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
  font-weight: 500;
}

/* ── Page Card ─────────────────────────────── */
.page-card {
  background: #fff;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Allow autocomplete dropdowns to escape card overflow */
#formulationSection {
  overflow: visible;
}

.page-card .page-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.page-card .page-card-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-card .page-card-header h5 i {
  color: var(--primary);
}

.page-card .page-card-body {
  padding: 24px;
}

/* ── Page Header ───────────────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-header h4 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.page-header p {
  color: #6b7280;
  font-size: 0.85rem;
  margin: 4px 0 0;
}

/* ── Buttons ───────────────────────────────── */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary-custom:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35);
}

/* ── Tables ────────────────────────────────── */
.table {
  font-size: 0.87rem;
}

.table thead th {
  background: #f8fdf8;
  color: var(--primary-dark);
  font-weight: 600;
  border-bottom: 2px solid #c8e6c9;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background: #f0faf0;
}

.badge-admin {
  background: #1b5e20;
  color: #a5d6a7;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-member {
  background: #e3f2fd;
  color: #1565c0;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-location {
  background: #f3f4f6;
  color: #374151;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
}

/* ── Form Styles ───────────────────────────── */
.form-label {
  font-weight: 500;
  font-size: 0.87rem;
  color: #374151;
}

.form-control,
.form-select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 0.88rem;
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

/* ── Alert ─────────────────────────────────── */
.alert-custom {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.87rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: none;
}

.alert-custom i {
  margin-top: 2px;
}

/* ── Login Page ────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--surface-dark) 0%, var(--surface-mid) 50%, #0d2e0d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 80% at 20% 20%, rgba(46, 125, 50, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 80% 80%, rgba(102, 187, 106, 0.07) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 48px 42px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.35);
}

.login-logo h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #111;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}

.login-logo p {
  color: #6b7280;
  font-size: 0.82rem;
  margin: 0;
}

.login-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  color: #fff;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

.login-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(46, 125, 50, 0.4);
}

/* ── User Info Card ────────────────────────── */
.user-info-card {
  background: linear-gradient(135deg, var(--surface-dark) 0%, #1a3a1a 100%);
  border-radius: var(--border-radius);
  padding: 24px;
  color: #fff;
  box-shadow: var(--shadow);
}

.user-info-card .info-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.user-info-card .info-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

/* ── Sidebar Overlay (mobile) ──────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1049;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-overlay.show {
    display: block;
  }

  #topbar {
    left: 0;
  }

  #topbar .topbar-toggle {
    display: block;
  }

  #main-content {
    margin-left: 0;
  }
}

@media (max-width: 575.98px) {
  #main-content {
    padding: 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-card .stat-value {
    font-size: 1.6rem;
  }
}

/* ── DataTables Override ───────────────────── */
.dataTables_wrapper .dataTables_filter input {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_length select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 4px 28px 4px 10px;
  min-width: 65px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  padding: 4px 10px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Background of QC Test ──────────────────── */
.bg-qctest-wrap {
  display: flex;
  border: 1.5px solid #2e7d32;
  border-radius: 6px;
  overflow: hidden;
  min-height: 110px;
}

.bg-qctest-label {
  background: #fffde7;
  color: #1a1a1a;
  font-weight: 600;
  font-size: .85rem;
  padding: 14px 16px;
  min-width: 170px;
  max-width: 170px;
  display: flex;
  align-items: center;
  border-right: 1.5px solid #2e7d32;
  line-height: 1.4;
}

.bg-qctest-area {
  flex: 1;
  border: none;
  outline: none;
  resize: vertical;
  padding: 12px 14px;
  font-size: .87rem;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  line-height: 1.6;
}

.bg-qctest-area:focus {
  background: #f9fff9;
  box-shadow: inset 0 0 0 2px #c8e6c9;
}

.bg-qctest-display {
  flex: 1;
  padding: 12px 14px;
  font-size: .87rem;
  color: #1a1a2e;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #fff;
}