/* assets/css/style.css - 5dmaty Invoices Design System */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-dark: #3730a3;
  --secondary: #64748b;
  --accent: #8b5cf6;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  --font-sans: 'Cairo', system-ui, -apple-system, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  display: block;
}

/* Layout Structure */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}
.sidebar-title {
  display: flex;
  flex-direction: column;
}
.sidebar-title h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.sidebar-title span {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  list-style: none;
}
.menu-category {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  padding: 14px 12px 6px;
  letter-spacing: 0.05em;
}
.menu-item {
  margin-bottom: 4px;
}
.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #cbd5e1;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  transition: var(--transition);
  position: relative;
}
.menu-link i {
  font-size: 1.15rem;
  width: 22px;
  text-align: center;
  color: #94a3b8;
  transition: var(--transition);
}
.menu-link:hover {
  background-color: var(--bg-sidebar-hover);
  color: #fff;
}
.menu-link:hover i {
  color: #fff;
}
.menu-link.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.menu-link.active i {
  color: #fff;
}
.menu-badge {
  margin-right: auto;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.menu-badge.badge-accent {
  background-color: #ef4444;
  color: #fff;
  animation: pulse 2s infinite;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.user-info-sm {
  flex: 1;
  overflow: hidden;
}
.user-name-sm {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role-sm {
  font-size: 0.74rem;
  color: #94a3b8;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

/* Topbar */
.topbar {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.mobile-toggle {
  display: none;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.mobile-toggle:hover {
  background: var(--border-light);
  color: var(--primary);
}
.topbar-mini-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.current-branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(99, 102, 241, 0.12));
  color: var(--primary-dark);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 220px;
}
.current-branch-tag.tag-central {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border-color: #fcd34d;
}
.branch-tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
}
.topbar-quick-btn:hover {
  background-color: var(--border-light);
  border-color: var(--primary);
  color: var(--primary);
}
.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: var(--transition);
}
.user-details-box {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.topbar-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user-role {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.logout-icon-link {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  font-size: 0.85rem;
  transition: var(--transition);
  background: rgba(239, 68, 68, 0.08);
}
.logout-icon-link:hover {
  background: var(--danger);
  color: #fff;
}

/* Action Icons in Topbar */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}
.icon-btn:hover {
  background-color: var(--border-light);
  color: var(--primary);
  border-color: var(--primary);
}
.icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 10px;
  height: 10px;
  background-color: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}
.icon-btn.active-audio {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #10b981;
}

/* Page Body */
.page-content {
  padding: 28px;
  flex: 1;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding: 18px 22px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}
.page-title {
  display: flex;
  flex-direction: column;
}
.page-title h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  line-height: 1.3;
}
.page-title h2 i {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(99, 102, 241, 0.15));
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  border: 1px solid rgba(79, 70, 229, 0.15);
}
.page-title p {
  color: #64748b;
  font-size: 0.86rem;
  margin-top: 6px;
  margin-bottom: 0;
  line-height: 1.5;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Welcome Dashboard Banner */
.welcome-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 6px 24px rgba(49, 46, 129, 0.16);
}
@media (max-width: 768px) {
  .welcome-banner {
    padding: 16px 14px;
    margin-bottom: 16px;
  }
  .welcome-banner h2 {
    font-size: 1.3rem !important;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.35);
}
.btn-success {
  background-color: var(--success);
  color: #fff;
}
.btn-success:hover {
  background-color: #059669;
  color: #fff;
}
.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--border-light);
  border-color: #cbd5e1;
}
.btn-danger {
  background-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: #dc2626;
  color: #fff;
}
.btn-outline-primary {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background-color: var(--primary-light);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
}

/* Cards & Surfaces */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* KPI Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.primary { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.success { background-color: var(--success-light); color: var(--success); }
.stat-icon.warning { background-color: var(--warning-light); color: var(--warning); }
.stat-icon.info { background-color: var(--info-light); color: var(--info); }
.stat-info h4 {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text-main);
  margin-top: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}
.form-label .optional {
  font-size: 0.78rem;
  font-weight: normal;
  color: var(--text-muted);
  margin-right: 4px;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #fff;
  color: var(--text-main);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
textarea.form-control {
  min-height: 110px;
  resize: vertical;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}
.table th {
  background-color: #f1f5f9;
  padding: 14px 16px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}
.table tr:last-child td {
  border-bottom: none;
}
.table tr:hover td {
  background-color: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background-color: var(--success-light); color: #065f46; }
.badge-warning { background-color: var(--warning-light); color: #92400e; }
.badge-danger { background-color: var(--danger-light); color: #991b1b; }
.badge-info { background-color: var(--info-light); color: #075985; }
.badge-primary { background-color: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background-color: #f1f5f9; color: #475569; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}
.pulse-badge {
  animation: pulse 1.8s infinite;
}

/* Alerts & Flash Messages */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.92rem;
}
.alert-success { background-color: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error, .alert-danger { background-color: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background-color: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info { background-color: #f0f9ff; border: 1px solid #bae6fd; color: #075985; }

/* Filter Tabs / Months Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 20px;
}
.filter-chip {
  padding: 8px 18px;
  border-radius: 9999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}
.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-chip.active {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

/* Chat Component */
.chat-container {
  display: flex;
  height: calc(100vh - 160px);
  min-height: 520px;
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  position: relative;
}
.chat-sidebar {
  width: 310px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background-color: #fafbfc;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 30;
}
.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}
.chat-sidebar-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}
.chat-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 999;
}
.chat-channel-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}
.channel-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}
.channel-item:hover, .channel-item.active {
  background-color: var(--primary-light);
}
.channel-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.channel-info h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}
.channel-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: #f8fafc;
}
.chat-main-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  z-index: 10;
}
.chat-messages {
  flex: 1;
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #f1f5f9;
  background-image: radial-gradient(#cbd5e1 0.75px, transparent 0.75px);
  background-size: 18px 18px;
  -webkit-overflow-scrolling: touch;
}
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  position: relative;
  word-break: break-word;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.msg-sent {
  align-self: flex-start;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-sent .msg-header {
  color: rgba(255, 255, 255, 0.85);
}
.msg-received {
  align-self: flex-end;
  background-color: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.msg-received .msg-header {
  color: #64748b;
}
.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.74rem;
  margin-bottom: 4px;
  opacity: 0.9;
}
.msg-sender {
  font-weight: 800;
}
.msg-time {
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
}
.msg-mini-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}
.msg-attachment-wrap {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
}
.msg-img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  transition: transform 0.2s ease;
}
.msg-img:hover {
  transform: scale(1.02);
}
.chat-composer {
  padding: 12px 18px;
  background-color: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-composer input[type="text"] {
  flex: 1;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: 9999px;
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: #f8fafc;
  transition: var(--transition);
}
.chat-composer input[type="text"]:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.chat-composer button:disabled {
  opacity: 0.65;
  cursor: not-allowed !important;
}
.pending-msg {
  background: #f0f7ff !important;
  color: #1e3a8a !important;
  border: 1.5px dashed #3b82f6 !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15) !important;
  animation: pulse-border 1.5s infinite ease-in-out;
}
@keyframes pulse-border {
  0%, 100% { border-color: #3b82f6; opacity: 1; }
  50% { border-color: #93c5fd; opacity: 0.8; }
}

/* Reception Stream Cards */
.reception-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.reception-card {
  background-color: #fff;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}
.reception-card.waiting {
  border-color: #f59e0b;
  background: linear-gradient(to bottom, #fffdfa, #ffffff);
}
.reception-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.reception-client-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}
.reception-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.reception-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 6px;
}
.reception-notes-box {
  background-color: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-main);
  margin: 12px 0;
  flex: 1;
  max-height: 120px;
  overflow-y: auto;
}
.reception-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* Invoice View & Paper Layout */
.invoice-paper-wrapper {
  max-width: 850px;
  margin: 0 auto;
}
.invoice-paper {
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  position: relative;
}
.invoice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 24px;
  margin-bottom: 24px;
}
.invoice-brand-col img {
  height: 60px;
  width: auto;
  margin-bottom: 10px;
}
.invoice-brand-col h2 {
  font-size: 1.4rem;
  font-weight: 900;
  color: #1e3a8a;
}
.invoice-brand-col p {
  font-size: 0.82rem;
  color: #64748b;
}
.invoice-meta-col {
  text-align: left;
  direction: ltr;
}
.invoice-serial-badge {
  display: inline-block;
  background-color: #eff6ff;
  border: 1.5px solid #bfdbfe;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 900;
  color: #1d4ed8;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.invoice-meta-item {
  font-size: 0.84rem;
  color: #475569;
  margin-bottom: 3px;
}
.invoice-meta-item strong {
  color: #0f172a;
}

.invoice-bill-to {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background-color: #f8fafc;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid #e2e8f0;
}
.bill-box h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 800;
  margin-bottom: 6px;
}
.bill-box p {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
}
.bill-box span {
  display: block;
  font-size: 0.84rem;
  color: #64748b;
}

.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.invoice-items-table th {
  background-color: #1e3a8a;
  color: #fff;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: right;
}
.invoice-items-table td {
  padding: 14px 16px;
  font-size: 0.92rem;
  border-bottom: 1px solid #e2e8f0;
}
.invoice-items-table tr:nth-child(even) td {
  background-color: #fafbfc;
}

.invoice-summary-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 30px;
}
.invoice-notes-area {
  flex: 1;
  background-color: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  font-size: 0.84rem;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.invoice-totals-box {
  width: 300px;
  border-collapse: collapse;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: #475569;
  border-bottom: 1px solid #f1f5f9;
}
.totals-row.grand-total {
  font-size: 1.15rem;
  font-weight: 900;
  color: #1e3a8a;
  background-color: #eff6ff;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1.5px solid #bfdbfe;
  margin-top: 6px;
}

/* Stamp & QR Verification Footer */
.invoice-footer-verification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 2px dashed #cbd5e1;
  margin-top: 24px;
}
.qr-verification-box {
  display: flex;
  align-items: center;
  gap: 16px;
}
.qr-code-img {
  width: 100px;
  height: 100px;
  padding: 6px;
  background: #fff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
}
.qr-text h5 {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
}
.qr-text p {
  font-size: 0.75rem;
  color: #64748b;
  max-width: 220px;
  margin-top: 4px;
}
.qr-text .verify-url {
  font-size: 0.72rem;
  font-family: monospace;
  color: #2563eb;
  font-weight: 700;
}
.official-stamp-box {
  position: relative;
  text-align: center;
}
.stamp-image {
  width: 150px;
  height: 150px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(30, 58, 138, 0.15));
}

/* Public Verification Page */
.verify-container {
  max-width: 650px;
  margin: 40px auto;
  padding: 0 16px;
}
.verify-card {
  background-color: #fff;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.verify-banner {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  padding: 32px 24px;
  text-align: center;
}
.verify-banner.invalid {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}
.verify-banner-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}
.verify-banner h2 {
  font-size: 1.45rem;
  font-weight: 900;
}
.verify-banner p {
  font-size: 0.88rem;
  opacity: 0.95;
  margin-top: 6px;
}
.verify-body {
  padding: 28px;
}
.verify-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.92rem;
}
.verify-row:last-child {
  border-bottom: none;
}
.verify-row-label {
  color: var(--text-muted);
  font-weight: 600;
}
.verify-row-value {
  color: var(--text-main);
  font-weight: 800;
}

/* Toast Notification Styles */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  animation: slideIn 0.3s ease-out;
  min-width: 280px;
  border-right: 4px solid var(--primary);
}
.toast.toast-success { border-color: var(--success); }
.toast.toast-danger { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 58px;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 44;
}

/* Ultra-Responsive Media Queries (100% Mobile & Smallest Devices Ready down to 320px) */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    top: 58px; /* Slides in UNDER the header */
    bottom: 0;
    height: calc(100vh - 58px);
    right: -280px;
    z-index: 45; /* Beneath topbar which has z-index: 50 */
    box-shadow: -6px 8px 25px rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .sidebar.open {
    right: 0;
  }
  .sidebar-header {
    display: none; /* Logo is already in the topbar above */
  }
  .sidebar-overlay {
    top: 58px;
    height: calc(100vh - 58px);
  }
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-container {
    height: calc(100vh - 140px);
  }
  .chat-sidebar {
    width: 260px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    top: 52px;
    height: calc(100vh - 52px);
  }
  .sidebar-overlay {
    top: 52px;
    height: calc(100vh - 52px);
  }
  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }
  .current-branch-tag {
    max-width: 130px;
    padding: 4px 8px;
    font-size: 0.74rem;
    gap: 4px;
  }
  .branch-tag-text {
    max-width: 95px;
  }
  .topbar-quick-btn {
    padding: 6px 10px;
  }
  .quick-btn-label {
    display: none;
  }
  .user-details-box {
    display: none;
  }
  .topbar-user-pill {
    padding: 2px 4px;
    border: none;
    background: transparent;
    gap: 6px;
  }
  .user-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  .logout-icon-link {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 0.92rem;
  }

  /* Full Screen Mobile Chat Experience (WhatsApp/Telegram Style) */
  .chat-container {
    height: calc(100vh - 125px);
    min-height: unset;
    border-radius: 12px;
    border: 1px solid var(--border);
    flex-direction: row;
    position: relative;
  }
  .chat-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -320px;
    width: 290px;
    height: 100vh;
    z-index: 1001;
    background-color: #fff;
    box-shadow: -6px 0 25px rgba(0, 0, 0, 0.25);
    border-left: none;
    border-right: none;
    max-height: none;
  }
  .chat-sidebar.mobile-open {
    right: 0 !important;
  }
  .chat-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
  }
  .chat-main {
    width: 100%;
    height: 100%;
  }
  .chat-main-header {
    padding: 10px 14px;
  }
  .chat-messages {
    padding: 12px;
    gap: 10px;
  }
  .msg-bubble {
    max-width: 86%;
    font-size: 0.88rem;
    padding: 8px 12px;
  }
  .chat-composer {
    padding: 8px 10px;
    gap: 6px;
  }
  .chat-composer input[type="text"] {
    padding: 10px 14px;
    font-size: 16px !important; /* Prevents auto-zoom on mobile */
  }
  .chat-composer button[type="submit"] {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  /* General Pages Responsiveness */
  .page-content {
    padding: 12px 10px;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .header-actions {
    width: 100%;
    gap: 8px;
  }
  .header-actions .btn {
    flex: 1 1 auto;
    font-size: 0.84rem;
    padding: 8px 12px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
    gap: 10px;
  }
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }
  .stat-value {
    font-size: 1.25rem;
  }
  .reception-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card {
    padding: 14px 12px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .form-control, input, select, textarea {
    font-size: 16px !important;
  }
  .invoice-paper {
    padding: 16px 12px;
  }
  .invoice-top {
    flex-direction: column;
    gap: 14px;
  }
  .invoice-brand-col h2 {
    font-size: 1.15rem;
  }
  .invoice-serial-badge {
    font-size: 1rem;
    padding: 4px 10px;
  }
  .invoice-meta-col {
    text-align: right;
    direction: rtl;
  }
  .invoice-bill-to {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .invoice-summary-section {
    flex-direction: column;
    gap: 14px;
  }
  .invoice-totals-box {
    width: 100%;
  }
  .invoice-footer-verification {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  .qr-verification-box {
    flex-direction: column;
    text-align: center;
  }
  .stamp-image {
    width: 110px;
    height: 110px;
  }
}

/* Ultra-Small Phones (Screen width 320px - 480px) */
@media (max-width: 480px) {
  body {
    font-size: 13.5px;
  }
  .sidebar {
    top: 48px;
    height: calc(100vh - 48px);
  }
  .sidebar-overlay {
    top: 48px;
    height: calc(100vh - 48px);
  }
  .topbar {
    padding: 6px 8px;
    gap: 6px;
  }
  .current-branch-tag {
    max-width: 100px;
    padding: 3px 6px;
    font-size: 0.7rem;
  }
  .branch-tag-text {
    max-width: 75px;
  }
  .topbar-end {
    gap: 4px;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 0.88rem;
  }
  .topbar-quick-btn {
    padding: 5px 8px;
    font-size: 0.78rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .page-title h2 {
    font-size: 1.2rem;
  }
  .btn {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
  .filter-bar {
    gap: 6px;
    padding-bottom: 6px;
  }
  .filter-chip {
    padding: 6px 12px;
    font-size: 0.76rem;
  }
  .table th, .table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
  .invoice-items-table th, .invoice-items-table td {
    padding: 8px 5px;
    font-size: 0.78rem;
  }
  .msg-bubble {
    max-width: 92%;
    font-size: 0.85rem;
  }
  .chat-container {
    height: calc(100vh - 110px);
  }
  .toast-container {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
  .toast {
    min-width: unset;
    width: 100%;
    font-size: 0.8rem;
    padding: 10px 12px;
  }
}

