@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-gradient: linear-gradient(160deg, #12070c 0%, #090306 54%, #18100d 100%);
  --bg: #090406;
  --surface-glass: rgba(24, 14, 17, 0.86);
  --surface-glass-hover: rgba(34, 20, 24, 0.94);
  --border-glass: rgba(229, 171, 132, 0.22);
  --border-glass-focus: rgba(229, 171, 132, 0.56);
  --ink: #fffdfd;
  --muted: #a6949b;
  --line: rgba(234, 223, 225, 0.08);
  --brand-gradient: linear-gradient(135deg, #a72349 0%, #e28b62 100%);
  --brand: #a72349;
  --brand-light: #e55c7f;
  --accent: #e28b62;
  --mint: #25d366; /* WhatsApp Green */
  --mint-bg: rgba(37, 211, 102, 0.12);
  --danger: #ff4772;
  --danger-bg: rgba(255, 71, 114, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 20px rgba(167, 35, 73, 0.3);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #090306;
}
::-webkit-scrollbar-thumb {
  background: #361722;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}

/* App Shell Layout */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

/* Sidebar Navigation */
.sidebar {
  background: rgba(14, 6, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  color: #fff;
  padding: 30px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 35px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--brand-gradient);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.brand strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: block;
}

.brand span {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
  align-content: start;
  flex-grow: 1;
}

.nav-item {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  color: #fff;
  background: rgba(226, 139, 98, 0.08);
  transform: translateX(4px);
}

.nav-item.active {
  color: #fff;
  background: var(--brand-gradient);
  box-shadow: var(--shadow-glow);
  font-weight: 600;
}

/* User Account Display in Sidebar */
.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: grid;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
}

.user-info {
  font-size: 13px;
}

.user-info strong {
  display: block;
  color: #fff;
}

.user-info span {
  color: var(--muted);
  font-size: 11px;
}

.logout-button {
  background: rgba(255, 71, 114, 0.08);
  border: 1px solid rgba(255, 71, 114, 0.15);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.logout-button:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 71, 114, 0.3);
}

/* Main Area Layout */
.main {
  padding: 35px;
  min-width: 0;
}

/* Topbar styles */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.eyebrow {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin-bottom: 6px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 800;
  color: #fff;
  font-size: clamp(28px, 4vw, 36px);
  background: linear-gradient(135deg, #ffffff 30%, #ffd0c4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 20px;
  margin-bottom: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Glassmorphic Cards & Panels */
.kpi,
.panel,
.list-item,
.readiness-item {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi:hover,
.panel:hover,
.list-item:hover {
  background: var(--surface-glass-hover);
  border-color: var(--border-glass-focus);
  transform: translateY(-2px);
}

.panel {
  padding: 24px;
}

/* KPI Cards Layout */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 25px;
}

.kpi {
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brand-gradient);
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.kpi strong {
  display: block;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin-top: 10px;
}

/* Split grids */
.split-grid,
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 1.3fr);
  gap: 20px;
}

/* Forms layout & controls */
.form {
  display: grid;
  gap: 16px;
  align-content: start;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(14, 6, 10, 0.45);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-glass-focus);
  box-shadow: 0 0 10px rgba(226, 139, 98, 0.2);
  background: rgba(14, 6, 10, 0.6);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.country-phone-row {
  grid-template-columns: minmax(76px, 96px) minmax(0, 1fr);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  line-height: 1.35;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--mint);
}

/* Custom Styled Select */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23e28b62'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Buttons */
.primary,
.secondary-btn,
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary {
  background: var(--brand-gradient);
  color: #fff;
  padding: 0 24px;
  box-shadow: var(--shadow-glow);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(167, 35, 73, 0.5);
  filter: brightness(1.1);
}

.primary:active {
  transform: translateY(1px);
}

.secondary-btn {
  background: rgba(226, 139, 98, 0.08);
  border: 1px solid rgba(226, 139, 98, 0.25);
  color: var(--accent);
  padding: 0 18px;
}

.secondary-btn:hover {
  background: rgba(226, 139, 98, 0.15);
  color: #fff;
  border-color: var(--accent);
}

.refresh-btn {
  width: 44px;
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  color: var(--accent);
}

.refresh-btn:hover {
  background: rgba(226, 139, 98, 0.1);
  color: #fff;
  border-color: var(--border-glass-focus);
}

/* Status Badges */
.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.status-pill.success,
.badge.success {
  background: var(--mint-bg);
  color: var(--mint);
  border: 1px solid rgba(37, 211, 102, 0.2);
}

.status-pill.danger,
.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 114, 0.2);
}

.status-pill.warning,
.badge.warning {
  background: rgba(226, 139, 98, 0.12);
  color: var(--accent);
  border: 1px solid rgba(226, 139, 98, 0.2);
}

.badge.muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Lists and list items */
.list {
  display: grid;
  gap: 12px;
  align-content: start;
}

.list-item {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.list-item-content {
  display: grid;
  gap: 4px;
}

.list-item-content strong {
  font-family: var(--font-display);
  font-size: 16px;
  color: #fff;
}

.list-item-content span {
  font-size: 13px;
  color: var(--muted);
}

.list-item-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--accent);
}

/* WhatsApp Pre-filled link Trigger button */
.whatsapp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--mint-bg);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: var(--mint);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.whatsapp-trigger:hover {
  background: var(--mint);
  color: #000;
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.4);
}

/* Bilingual Toggle Switch Header */
.lang-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-glass);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 6px 12px;
}

.lang-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.lang-label.active {
  color: var(--accent);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--accent);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: var(--brand-light);
}

/* Premium Login View overlay */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-gradient);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 30px;
  background: rgba(18, 8, 12, 0.75);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(226, 139, 98, 0.25);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: grid;
  gap: 25px;
}

.login-header {
  text-align: center;
}

.login-header .brand-mark {
  margin: 0 auto 15px;
}

.login-header h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.login-header p {
  color: var(--muted);
  font-size: 14px;
}

/* Toast message */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(150%);
  background: rgba(22, 11, 16, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass-focus);
  color: #fff;
  border-radius: 12px;
  padding: 14px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 90vw;
  text-align: center;
  z-index: 1100;
  font-weight: 500;
  font-size: 14px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Interactive tables / boards */
.board-container {
  overflow-x: auto;
  margin-top: 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
}

td {
  color: #f0e5e8;
  background: rgba(0, 0, 0, 0.1);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Inventory Alerts Grid list */
.inventory-list {
  display: grid;
  gap: 10px;
}

.inventory-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 16px;
  border-radius: 8px;
}

.inventory-info strong {
  display: block;
  font-size: 14px;
  color: #fff;
}

.inventory-info span {
  font-size: 12px;
  color: var(--muted);
}

.inventory-badge {
  font-weight: 700;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
}

.inventory-badge.low {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 114, 0.2);
}

.inventory-badge.normal {
  background: var(--mint-bg);
  color: var(--mint);
  border: 1px solid rgba(37, 211, 102, 0.2);
}

/* View Views Routing default hide */
.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 20px;
}

/* UI Adjustments for responsive viewports */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    z-index: 10;
    height: auto;
    min-height: 0;
    padding: 15px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    justify-content: stretch;
  }

  .brand {
    margin-bottom: 0;
    justify-content: flex-start;
  }

  .sidebar > div,
  .brand,
  .nav,
  .sidebar-footer {
    min-width: 0;
  }

  .nav {
    width: 100%;
    display: flex;
    overflow-x: auto;
    padding: 2px 0 10px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .nav-item {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 14px;
    transform: none;
  }

  .nav-item:hover,
  .nav-item.active {
    transform: none;
  }

  .sidebar-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    padding-top: 15px;
    margin-top: 0;
  }

  .logout-button {
    padding: 6px 12px;
  }

  .kpi-grid,
  .split-grid,
  .work-grid {
    grid-template-columns: 1fr;
  }
  
  .main {
    padding: 20px;
  }

  .primary,
  .secondary-btn,
  .refresh-btn {
    min-height: 48px;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 15px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .country-phone-row {
    grid-template-columns: minmax(74px, 88px) minmax(0, 1fr);
  }

  .form {
    gap: 14px;
  }

  .panel {
    padding: 18px;
  }
  
  th, td {
    padding: 10px 12px;
    font-size: 13px;
  }
}
