/* ShopLine Panel - Premium Design Overhaul */
/* Inspired by Linear.app meets Vercel Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* CSS Variables - Exact Color System */
:root {
  /* Background Colors */
  --bg-primary: #08090d;
  --bg-secondary: #0e1016;  
  --bg-card: #12141e;
  --bg-card-hover: #161824;
  --bg-input: #0c0d14;
  
  /* Border Colors */
  --border: #1c1f2e;
  --border-hover: #282c3e;
  --border-focus: #3B82F6;
  
  /* Text Colors */
  --text-primary: #e4e7f0;
  --text-secondary: #8b90a0;
  --text-muted: #5a5f72;
  
  /* Brand Colors */
  --blue: #3B82F6;
  --blue-hover: #2563EB;
  --blue-subtle: rgba(59,130,246,0.08);
  --green: #10B981;
  --green-subtle: rgba(16,185,129,0.08);
  --red: #EF4444;
  --red-subtle: rgba(239,68,68,0.08);
  --yellow: #F59E0B;
  --yellow-subtle: rgba(245,158,11,0.08);
  --purple: #8B5CF6;
  --purple-subtle: rgba(139,92,246,0.08);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  
  /* Transitions */
  --transition: all 0.15s ease;
  
  /* Shadows */
  --shadow-card: 0 20px 50px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03) inset;
  --shadow-toast: 0 10px 30px rgba(0,0,0,0.3);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
  direction: rtl;
  overflow: hidden;
  height: var(--app-height, 100vh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* Typography */
h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.text-small {
  font-size: 12px;
  font-weight: 500;
}

.text-mono {
  font-family: var(--font-mono);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* Login Page Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(ellipse at top, #0f1629 0%, #08090d 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.04);
  text-align: center;
  position: relative;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content h2 {
  margin-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo-area {
  margin-bottom: 24px;
}

.logo-monogram {
  width: 64px;
  height: 64px;
  background: var(--blue);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin: 0 auto 16px;
}

.modal-content h2 {
  margin: 0 0 8px 0;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
}

.modal-subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 13px;
}

.temp-password-notice {
  background: var(--yellow-subtle);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  color: var(--yellow);
  font-size: 13px;
  text-align: right;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
  text-align: right;
}

/* Fix date/time inputs for dark theme */
input[type="date"], 
input[type="time"], 
input[type="datetime-local"] {
  color-scheme: dark;
}

/* Use JetBrains Mono for numbers */
.stat-value, 
.financial-amount, 
.badge-number, 
td:nth-child(n) {
  font-family: 'JetBrains Mono', monospace;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 44px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0 16px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: var(--transition);
  direction: rtl;
}

.form-group input::placeholder,
.form-group select::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-group textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 16px;
  resize: vertical;
}

.form-group select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235a5f72' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: left 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-left: 44px;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 38px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition);
  font-family: var(--font-sans);
  position: relative;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover {
  background: var(--blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--red-subtle);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover {
  background: var(--red);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-small {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-large {
  height: 44px;
  padding: 0 20px;
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Error Message */
.error-message {
  background: var(--red-subtle);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--red);
  font-size: 13px;
  text-align: right;
  margin-top: 16px;
  display: none;
}

.error-message.show {
  display: block;
  animation: slideIn 0.3s ease;
}

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

/* Main App Layout */
#appContainer {
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100vh);
  overflow: hidden;
  opacity: 0;
  animation: fadeIn 0.3s ease 0.1s forwards;
}

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

/* Header */
.header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 1000;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header h1 i {
  color: var(--blue);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#userDisplayName {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

#userDisplayName::before {
  content: '';
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Main Container */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 999;
}

.nav-menu {
  list-style: none;
  padding: 8px;
  flex: 1;
}

.nav-menu li {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.nav-link i {
  font-size: 18px;
  opacity: 0.6;
  transition: var(--transition);
}

.nav-link:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
}

.nav-link:hover i {
  opacity: 1;
}

.nav-link.active {
  background: var(--blue-subtle);
  color: var(--blue);
  border-right: 2px solid var(--blue);
}

.nav-link.active i {
  opacity: 1;
}

/* Logo Area */
.sidebar::before {
  content: 'ShopLine';
  display: block;
  padding: 20px 24px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 28px;
  right: 170px;
  width: 6px;
  height: 6px;
  background: var(--blue);
  border-radius: 50%;
}

/* Main Content */
.main-content {
  flex: 1;
  background: var(--bg-primary);
  padding: 24px;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: var(--transition);
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 20px;
}

.card-body.no-padding {
  padding: 0;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

.table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 16px 12px;
  text-align: right;
  border-bottom: 2px solid var(--border);
}

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

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

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

/* Action Buttons in Tables */
.table .action-buttons {
  display: flex;
  gap: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-urgent,
.badge-critical {
  color: var(--red);
  background: var(--red-subtle);
}

.badge-high {
  color: var(--yellow);
  background: var(--yellow-subtle);
}

.badge-medium {
  color: var(--blue);
  background: var(--blue-subtle);
}

.badge-low {
  color: var(--green);
  background: var(--green-subtle);
}

.badge-open {
  color: var(--red);
  background: var(--red-subtle);
}

.badge-in-progress {
  color: var(--yellow);
  background: var(--yellow-subtle);
}

.badge-done,
.badge-resolved {
  color: var(--green);
  background: var(--green-subtle);
}

.badge-closed {
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
}

/* Financial Summary Cards */
.financial-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.financial-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.financial-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.financial-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.financial-icon.income {
  background: var(--green-subtle);
  color: var(--green);
}

.financial-icon.expense {
  background: var(--red-subtle);
  color: var(--red);
}

.financial-icon.balance {
  background: var(--blue-subtle);
  color: var(--blue);
}

.financial-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}

.financial-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.financial-amount.income {
  color: var(--green);
}

.financial-amount.expense {
  color: var(--red);
}

.financial-amount.balance {
  color: var(--blue);
}

.financial-amount.negative {
  color: var(--red) !important;
}

@media (max-width: 768px) {
  .financial-summary {
    grid-template-columns: 1fr;
  }
}

/* Dashboard Stats */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 12px;
}

.stat-value.cpu {
  color: var(--blue);
}

.stat-value.ram {
  color: var(--purple);
}

.stat-value.disk {
  color: var(--green);
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-fill.cpu {
  background: linear-gradient(90deg, var(--blue), var(--blue-hover));
}

.progress-fill.ram {
  background: linear-gradient(90deg, var(--purple), #7C3AED);
}

.progress-fill.disk {
  background: linear-gradient(90deg, var(--green), #059669);
}

@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}

/* Chat Styles */
.chat-container {
  height: calc(var(--app-height, 100vh) - 200px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  height: calc(100vh - 280px);
}

.message {
  max-width: 65%;
  word-wrap: break-word;
  animation: messageIn 0.2s ease;
}

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

.message.own {
  align-self: flex-start;
  background: var(--blue);
  color: white;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
}

.message.other {
  align-self: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  color: var(--text-primary);
}

.message-sender {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}

.message-sender.marom {
  color: var(--blue);
}

.message-sender.bar {
  color: var(--green);
}

.message-sender.lenny {
  color: var(--purple);
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}

.message.own .message-time {
  color: rgba(255,255,255,0.7);
}

.chat-input-area {
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  box-sizing: border-box;
}

.chat-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--blue-subtle);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  background: var(--blue);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 16px;
}

.chat-send-btn:hover {
  background: var(--blue-hover);
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  min-height: 300px;
  animation: fadeIn 0.3s ease;
}

.empty-state-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 300px;
  line-height: 1.5;
}

.empty-state .btn {
  margin-top: 8px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  max-width: 350px;
  box-shadow: var(--shadow-toast);
  display: none;
  z-index: 10000;
  animation: toastIn 0.3s ease;
}

.toast.success {
  border-color: var(--green);
}

.toast.success::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
}

.toast.error {
  border-color: var(--red);
}

.toast.error::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

.toast.show {
  display: block;
}

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

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  font-size: 14px;
  color: var(--text-muted);
  gap: 12px;
}

.loading i {
  font-size: 18px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* System Info */
.system-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.system-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.system-info-item:last-child {
  border-bottom: none;
}

.system-info-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.system-info-value {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

/* Hamburger Menu Button */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
  flex-shrink: 0;
}

.menu-toggle:hover {
  background: rgba(255,255,255,0.05);
}

.menu-toggle.active {
  color: var(--blue);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Show hamburger */
  .menu-toggle {
    display: flex;
  }
  
  .main-container {
    flex-direction: column;
  }
  
  /* Sidebar slides in from right */
  .sidebar {
    position: fixed;
    top: 52px;
    right: 0;
    height: calc(100dvh - 52px);
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    box-shadow: none;
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -5px 0 30px rgba(0,0,0,0.3);
  }
  
  /* Overlay behind sidebar */
  .sidebar.open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 260px;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: -1;
  }
  
  /* Backdrop when sidebar is open */
  .sidebar.open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 260px;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }
  
  /* Header */
  .header {
    padding: 0 12px;
    height: 52px;
  }
  
  .header h1 {
    font-size: 14px;
    white-space: nowrap;
  }
  
  .header h1 i {
    display: none;
  }
  
  /* User info compact */
  .user-info {
    gap: 6px;
  }
  
  #userDisplayName {
    font-size: 12px;
  }
  
  #userDisplayName::before {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }
  
  .user-info .btn {
    height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }
  
  .user-info .btn i {
    font-size: 12px;
  }
  
  /* Hide change password button text on mobile */
  #changePasswordBtn {
    font-size: 0;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }
  
  #changePasswordBtn i {
    font-size: 14px;
  }
  
  #logoutBtn {
    font-size: 0;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }
  
  #logoutBtn i {
    font-size: 14px;
  }
  
  /* Main content full width */
  .main-content {
    padding: 12px;
    max-width: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  
  /* Chat module: edge-to-edge on mobile */
  .main-content:has(.chat-container) {
    padding: 0;
    overflow: hidden;
    height: 100%;
  }
  
  /* Cards */
  .card-body {
    padding: 12px;
  }
  
  .card-header {
    padding: 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  /* Forms */
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    height: 48px;
    font-size: 16px; /* prevents iOS zoom */
  }
  
  .form-group textarea {
    height: auto;
    min-height: 80px;
  }
  
  .form-group label {
    font-size: 11px;
  }
  
  /* Buttons full width (except in chat input area and header) */
  .card .btn,
  .modal .btn,
  form .btn {
    width: 100%;
    height: 44px;
    font-size: 14px;
  }
  
  .btn-small {
    height: 36px;
  }
  
  /* Tables responsive */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  
  .table thead th,
  .table tbody td {
    padding: 10px 8px;
    font-size: 12px;
    white-space: nowrap;
  }
  
  .table .action-buttons {
    flex-direction: column;
    gap: 4px;
  }
  
  .table .action-buttons .btn {
    width: auto;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }
  
  /* Chat mobile - WhatsApp-like full screen */
  .chat-container {
    height: calc(var(--app-height, 100vh) - 52px) !important;
    border-radius: 0;
    border: none;
  }
  
  .chat-messages {
    flex: 1;
    min-height: 0;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  .chat-input-area {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  
  .message {
    max-width: 85%;
  }
  
  .chat-input {
    min-height: 44px;
    height: auto;
    font-size: 16px; /* prevents iOS zoom */
    padding: 10px 16px;
  }
  
  .chat-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
  }
  
  .chat-attach-btn {
    flex-shrink: 0;
  }
  
  /* Financial summary cards */
  .financial-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .financial-card {
    padding: 14px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  
  .financial-amount {
    font-size: 22px;
  }
  
  /* Dashboard stats */
  .dashboard-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  /* Empty states */
  .empty-state {
    padding: 40px 16px;
    min-height: 200px;
  }
  
  .empty-state-icon {
    font-size: 36px;
  }
  
  /* Toast */
  .toast {
    right: 12px;
    left: 12px;
    max-width: none;
  }
  
  /* Modal (login/password) */
  .modal-content {
    margin: 16px;
    padding: 24px 20px;
    max-width: none;
    width: calc(100% - 32px);
  }
  
  .logo-monogram {
    width: 56px;
    height: 56px;
    font-size: 20px;
    border-radius: 14px;
  }
  
  /* System info */
  .system-info {
    grid-template-columns: 1fr;
  }
  
  /* Form grid always single column */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Badges smaller */
  .badge {
    height: 22px;
    padding: 0 8px;
    font-size: 10px;
  }
}

/* Focus States */
button:focus,
.btn:focus,
input:focus,
select:focus,
textarea:focus,
.nav-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-subtle);
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.gap-4 { gap: 32px; }

/* Animation Utilities */
.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-up {
  animation: slideUp 0.3s ease;
}

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

/* Print Styles */
@media print {
  .header,
  .sidebar,
  .chat-input-area,
  .btn,
  .toast {
    display: none !important;
  }
  
  .main-content {
    padding: 0;
    max-width: none;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
/* Login button full width */
.modal-content .btn-primary {
  width: 100%;
  height: 44px;
  font-size: 15px;
}

/* Remove instructions section from chat */
/* Fix financial summary - ensure monospace numbers */
.stat-value, .financial-value, .summary-value {
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-weight: 700;
}

/* Small phones */
@media (max-width: 380px) {
  .header h1 {
    font-size: 13px;
  }
  
  #userDisplayName {
    display: none;
  }
  
  .user-info .btn {
    padding: 0 6px;
    font-size: 10px;
  }
  
  .modal-content {
    padding: 20px 16px;
  }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: #888;
  font-size: 0.85rem;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #888;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.typing-text { margin-right: 6px; }

/* Chat attach button */
.chat-attach-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 16px;
  flex-shrink: 0;
}
.chat-attach-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Chat image thumbnail */
.chat-image-thumb {
  max-width: 300px;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-image-thumb:hover { opacity: 0.85; }
.chat-image-link { display: inline-block; }

/* Message time positioning - RTL: time on left */
.message .message-time {
  text-align: left;
}

/* PWA Install button */
.install-app-link {
  background: linear-gradient(135deg, var(--blue-subtle), transparent) !important;
  border: 1px dashed var(--blue) !important;
  border-radius: 8px !important;
  margin: 8px 12px !important;
}
.install-app-link:hover {
  background: var(--blue-subtle) !important;
  border-style: solid !important;
}
.install-app-link i {
  color: var(--blue) !important;
}
