/* Apply Cairo font globally */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

/* ألوان المجلس العربي للاختصاصات الصحية الرسمية */
:root {
  --council-green: #156b68;
  --council-green-hover: #0f5a57;
  --council-green-light: #e8f4f3;
  --council-gold: #caa453;
  --council-gold-hover: #b8934a;
  --council-gold-light: #faf6ed;

  /* Additional colors */
  --gray-50: #f8f9fa;
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-300: #ced4da;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-900: #212529;
}

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

body {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--gray-50);
  color: var(--gray-900);
}

/* Council color utilities */
.text-council-green {
  color: var(--council-green) !important;
}

.text-council-gold {
  color: var(--council-gold) !important;
}

.bg-council-green {
  background-color: var(--council-green) !important;
}

.bg-council-green-light {
  background-color: var(--council-green-light) !important;
  background-color: var(--council-green-hover) !important;
}

.hover\:bg-council-gold-hover:hover {
  background-color: var(--council-gold-hover) !important;
}

/* Council-themed buttons */
.btn-council-green {
  background-color: var(--council-green);
  border-color: var(--council-green);
  color: white;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  transition: all 0.3s ease;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
}

.btn-council-green:hover {
  background-color: var(--council-green-hover);
  border-color: var(--council-green-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-council-gold {
  background-color: var(--council-gold);
  border-color: var(--council-gold);
  color: white;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  transition: all 0.3s ease;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-council-gold i {
  font-size: 0.9rem;
}

.btn-council-gold:hover {
  background-color: var(--council-gold-hover);
  border-color: var(--council-gold-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Navigation bar with council theme */
.council-navbar {
  background: linear-gradient(135deg, var(--council-green) 0%, #0f5a57 100%);
  border-bottom: 3px solid var(--council-gold);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: relative;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.mobile-menu-toggle:hover {
  opacity: 0.8;
}

.mobile-menu-toggle:active {
  opacity: 0.6;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.navbar-brand img {
  height: 3.25rem;
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

.navbar-brand-icon {
  width: 2.4rem;
  height: 2.4rem;
  color: var(--council-gold);
}

.navbar-title {
  color: var(--council-gold);
  font-weight: 700;
  font-size: 1.4rem;
  white-space: nowrap;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid white;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-council-green {
  background-color: var(--council-green-light);
  color: var(--council-green);
}

.badge-council-gold {
  background-color: var(--council-gold);
  color: white;
}

/* Navigation links */
.nav-links {
  display: flex;
  gap: 0.5rem;
  margin: 0 2rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-link.active {
  background-color: white;
  color: var(--council-green);
  font-weight: 600;
}

/* Main Content Layout */
.main-content {
  flex: 1;
  display: flex;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  height: calc(100vh - 120px);
}

/* Sidebar with council theme */
.council-sidebar {
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  background: linear-gradient(180deg, var(--gray-50) 0%, white 100%);
  border-left: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.sidebar-header {
  margin-bottom: 1.5rem;
}

.new-chat-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--council-green) 0%, var(--council-green-hover) 100%);
  color: white;
  border: none;
  padding: 0.875rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
}

.council-sidebar-item {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
  background: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0; /* مهم للـ text-overflow */
}

.council-sidebar-item:hover {
  background-color: var(--council-green-light);
  border-color: var(--council-green);
  color: var(--council-green);
}

.council-sidebar-item.active {
  background: linear-gradient(135deg, var(--council-green) 0%, var(--council-green-hover) 100%);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.chat-item-content {
  flex: 1;
  min-width: 0; /* مهم للـ text-overflow */
  overflow: hidden;
}

.chat-item-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chat-item-date {
  font-size: 0.75rem;
  opacity: 0.7;
}

.chat-item-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.council-sidebar-item:hover .chat-item-actions,
.council-sidebar-item.active .chat-item-actions {
  opacity: 1;
}

.chat-action-btn {
  padding: 0.25rem 0.4rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
}

.chat-action-btn:hover {
  transform: scale(1.1);
}

.chat-action-btn.edit {
  background: var(--council-gold);
  color: white;
}

.chat-action-btn.delete {
  background: #dc3545;
  color: white;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f6f8;
  position: relative;
}

/* Knowledge Selection Panel (Above Messages) */
.knowledge-selection-panel {
  background: white;
  border-bottom: 2px solid var(--gray-200);
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.knowledge-selection-content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

.knowledge-type-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.knowledge-label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.95rem;
  white-space: nowrap;
}

.knowledge-select {
  flex: 1;
  min-width: 220px;
  padding: 0.625rem 1rem;
  border: 2px solid var(--gray-300);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  background: white;
  color: var(--gray-900); /* Firefox fix */
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Cairo', sans-serif;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23495057' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  padding-left: 2.5rem;
}

.knowledge-select option {
  color: var(--gray-900);
  background: white;
  padding: 0.5rem;
}

.knowledge-select:hover {
  border-color: var(--council-green);
}

.knowledge-select:focus {
  outline: none;
  border-color: var(--council-green);
  box-shadow: 0 0 0 3px rgba(21, 107, 104, 0.1);
}

.file-selection-section {
  background: var(--gray-50);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--gray-200);
}

.file-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-selection-label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.9rem;
}

.files-count {
  color: var(--council-gold);
  font-weight: bold;
  font-size: 1rem;
}

.file-selection-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-select-action {
  padding: 0.4rem 0.75rem;
  background: var(--council-green);
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  font-family: 'Cairo', sans-serif;
}

.btn-select-action:hover {
  background: var(--council-green-hover);
  transform: translateY(-1px);
}

.btn-deselect {
  background: var(--gray-600);
}

.btn-deselect:hover {
  background: var(--gray-700);
}

.file-search-input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  transition: all 0.2s;
  font-family: 'Cairo', sans-serif;
}

.file-search-input:focus {
  outline: none;
  border-color: var(--council-green);
  box-shadow: 0 0 0 3px rgba(21, 107, 104, 0.1);
}

.files-list-container {
  max-height: 280px; /* ~4 files at 70px each */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.files-list-container::-webkit-scrollbar {
  width: 6px;
}

.files-list-container::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.files-list-container::-webkit-scrollbar-thumb {
  background: var(--gray-600);
  border-radius: 3px;
}

.files-list-container::-webkit-scrollbar-thumb:hover {
  background: var(--gray-700);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
  background: #e5ddd5; /* WhatsApp-like background */
  background-image: 
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 20px
    );
}

.messages-stream {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 3vw;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: var(--gray-600);
}

.empty-state-icon {
  width: 5rem;
  height: 5rem;
  color: var(--gray-300);
}

.empty-state-text {
  font-size: 1.1rem;
  color: var(--gray-500);
}

/* Chat messages - WhatsApp Style (All messages on right) */

.message-row {
  width: 100%;
  display: flex;
  padding: 0.25rem 0;
  animation: fadeIn 0.25s ease-out;
  justify-content: flex-end; /* All messages on right */
}

.message-row-user,
.message-row-ai {
  justify-content: flex-end; /* Both on right side */
}

.message-row-wide {
  justify-content: flex-end; /* Wide messages also on right */
  padding: 0 0.5rem;
}

.message-bubble {
  max-width: 75%;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* RTL messages (Arabic) */
.message-bubble[dir="rtl"] {
  text-align: right;
  direction: rtl;
  border-top-right-radius: 0;
  border-top-left-radius: 8px;
}

/* LTR messages (English) */
.message-bubble[dir="ltr"] {
  text-align: left;
  direction: ltr;
  border-top-left-radius: 0;
  border-top-right-radius: 8px;
}

/* User messages - Green like WhatsApp */
.message-row-user .message-bubble {
  background: #dcf8c6;
  color: #000;
  margin-left: auto;
}

/* AI messages - White/Light gray like WhatsApp */
.message-row-ai .message-bubble {
  background: #ffffff;
  color: #000;
  margin-left: auto;
  border: 1px solid #e0e0e0;
}

.message-bubble-wide {
  max-width: 85%;
  padding: 0.75rem 1.1rem;
}

.message-row-ai.message-row-wide .message-bubble {
  border-radius: 8px;
  border-top-right-radius: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  margin-left: auto;
  margin-right: 0;
}

.message-meta {
  display: flex;
  gap: 0.4rem;
  font-size: 0.75rem;
  opacity: 0.7;
}

.message-row-user .message-meta {
  justify-content: flex-end;
  color: #667781;
  font-weight: 400;
}

.message-row-ai .message-meta {
  justify-content: flex-end;
  color: #667781;
  font-weight: 400;
}

.message-row-wide .message-meta {
  justify-content: flex-end;
}

.message-time {
  font-size: 0.7rem;
  color: #667781;
  margin-top: 0.25rem;
}

/* Chat input area */
.chat-input-wrapper {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: #f0f2f5;
  padding: 0.75rem 0 1rem;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
}

.input-container {
  background: white;
  border-radius: 24px;
  border: 1px solid #e0e0e0;
  padding: 0.4rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: calc(100% - 14vw);
  max-width: 960px;
}

.input-container:focus-within {
  border-color: #25d366;
  box-shadow: 0 0 0 0.25rem rgba(21, 107, 104, 0.15);
}

.file-upload-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.file-upload-btn:hover {
  background-color: var(--gray-100);
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  padding: 0.5rem;
  max-height: 150px;
  min-height: 24px;
}

.message-text {
  white-space: inherit;
}

.global-footer {
  background: linear-gradient(120deg, rgba(21, 107, 104, 0.95), #0f5a57);
  color: white;
  padding: 2rem 1rem;
  margin-top: 3rem;
  border-top: 4px solid #caa453;
}

.global-footer__container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
}

.global-footer__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.global-footer__logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: contain;
  background: white;
  padding: 6px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.global-footer__title {
  font-weight: 700;
  margin: 0;
}

.global-footer__subtitle {
  margin: 0;
  opacity: 0.85;
  font-size: 0.9rem;
}

.global-footer__meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.95rem;
  text-align: left;
}

@media (max-width: 768px) {
  .global-footer__container {
    text-align: center;
    flex-direction: column;
  }

  .global-footer__meta {
    text-align: center;
  }
}

.send-btn {
  background: linear-gradient(135deg, #f8d08a, var(--council-gold));
  color: #1f2a37;
  border: none;
  padding: 0.65rem;
  border-radius: 50%;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  gap: 0;
  box-shadow: 0 8px 20px rgba(202, 164, 83, 0.35);
  flex-shrink: 0;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(202, 164, 83, 0.45);
}

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

/* Select inputs with council theme */
.council-select {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background: white;
  cursor: pointer;
}

.council-select:focus {
  border-color: var(--council-green);
  outline: none;
  box-shadow: 0 0 0 0.25rem rgba(21, 107, 104, 0.15);
}

/* Loading spinner with council colors */
.council-spinner {
  border: 3px solid var(--council-green-light);
  border-top-color: var(--council-green);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  animation: spin 1s linear infinite;
}

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

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Responsive Design - Mobile First
   ======================================== */

/* Extra Small Devices (phones, less than 576px) */
@media (max-width: 575px) {
  .council-navbar {
    overflow-x: visible;
  }

  .navbar-content {
    padding: 0.5rem 0.75rem;
    flex-wrap: nowrap;
    justify-content: space-between;
  }

  /* Logo and title on right, menu toggle on left */
  .navbar-brand {
    order: 1;
    flex: 0 1 auto;
  }

  .mobile-menu-toggle {
    order: 3;
    display: block !important;
  }

  .navbar-user {
    order: 2;
    gap: 0;
  }

  .user-avatar,
  .user-info,
  .user-name {
    display: none !important;
  }

  /* Hide logout text on mobile, keep icon only */
  .navbar-user .btn-council-gold .logout-text {
    display: none !important;
  }

  .navbar-user .btn-council-gold {
    padding: 0.5rem !important;
    min-width: auto !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
  }

  .navbar-user .btn-council-gold i {
    font-size: 1rem !important;
    margin: 0 !important;
  }

  .navbar-title {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .nav-links {
    display: none;
  }

  /* Admin links in sidebar for mobile */
  .sidebar-admin-section {
    display: block;
    border-top: 1px solid rgba(21, 107, 104, 0.15);
    padding: 0.75rem;
    margin-top: auto;
  }

  .sidebar-admin-section .sidebar-section-title {
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
  }

  .sidebar-admin-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    color: var(--council-green, #156b68);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    transition: background 0.2s;
  }

  .sidebar-admin-link:hover,
  .sidebar-admin-link:active {
    background: rgba(21, 107, 104, 0.08);
  }

  .sidebar-admin-link i {
    font-size: 0.9rem;
    width: 1.2rem;
    text-align: center;
  }

  .council-sidebar {
    position: fixed;
    right: -100%;
    top: 0;
    height: 100vh;
    width: 85vw;
    max-width: 300px;
    z-index: 1001;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  }

  .council-sidebar.open {
    right: 0;
  }

  .main-content {
    height: calc(100vh - 60px);
    padding: 0.5rem;
  }

  .chat-container {
    padding: 0.5rem;
  }

  .messages-container {
    padding: 0.5rem;
  }

  .chat-message-user,
  .chat-message-ai {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    word-break: break-word;
  }

  .message-row-ai .message-meta {
    justify-content: flex-start;
    color: #818694;
    font-weight: 500;
  }

  .message-row-wide .message-meta {
    justify-content: flex-end;
  }

  .message-input-container {
    padding: 0.5rem;
  }

  .message-input {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 0.6rem;
    min-height: 44px; /* iOS minimum tap target */
  }

  .send-btn {
    width: 44px;
    height: 44px;
    padding: 0.5rem;
  }

  .send-btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Knowledge base selectors */
  .council-select {
    font-size: 16px !important; /* Prevents iOS zoom */
    min-height: 44px;
  }

  /* Buttons minimum size for mobile */
  .btn-council-green,
  .btn-council-gold {
    min-height: 44px;
    font-size: 0.9rem;
  }

  .council-sidebar-item {
    padding: 0.85rem;
    min-height: 2.5rem;
    font-size: 0.9rem;
  }

  /* Files page responsive */
  .files-container {
    padding: 0.5rem;
  }

  .file-upload-section,
  .files-list {
    padding: 0.75rem;
  }

  .file-item {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  /* Analytics page responsive */
  .analytics-container {
    padding: 0.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .data-table {
    font-size: 0.85rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }

  /* Modal responsive */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 1rem;
    max-height: 90vh;
  }

  .modal-body {
    padding: 1rem;
  }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
  .council-navbar {
    overflow-x: visible;
  }

  .navbar-content {
    padding: 0.75rem 1rem;
  }

  .navbar-title {
    font-size: 1rem;
  }

  .nav-links {
    display: none;
  }

  .council-sidebar {
    position: fixed;
    right: -100%;
    top: 0;
    height: 100vh;
    width: 320px;
    z-index: 1001;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  }

  .council-sidebar.open {
    right: 0;
  }

  .main-content {
    height: calc(100vh - 70px);
    padding: 0.75rem;
  }

  .chat-message-user,
  .chat-message-ai {
    max-width: 85%;
    padding: 0.85rem;
    font-size: 0.95rem;
  }

  .message-input {
    font-size: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
  .council-sidebar {
    width: 280px;
  }

  .chat-message-user,
  .chat-message-ai {
    max-width: 75%;
  }

  .main-content {
    height: calc(100vh - 80px);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    width: 85vw;
    max-width: 600px;
  }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199px) {
  .council-sidebar {
    width: 300px;
  }

  .chat-message-user,
  .chat-message-ai {
    max-width: 70%;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-content {
    width: 70vw;
    max-width: 700px;
  }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .council-sidebar {
    width: 320px;
  }

  .chat-message-user,
  .chat-message-ai {
    max-width: 65%;
  }

  .main-content {
    max-width: 1400px;
    margin: 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-content {
    width: 60vw;
    max-width: 800px;
  }
}

/* Landscape Orientation for Mobile Devices */
@media (max-height: 500px) and (orientation: landscape) {
  .council-sidebar {
    width: 250px;
  }

  .main-content {
    height: calc(100vh - 50px);
  }

  .navbar-content {
    padding: 0.5rem 1rem;
  }

  .navbar-title {
    font-size: 0.9rem;
  }

  .message-input-container {
    padding: 0.5rem;
  }

  .chat-message-user,
  .chat-message-ai {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

  /* Increase touch targets */
  .btn-council-green,
  .btn-council-gold {
    min-height: 44px;
    min-width: 44px;
  }
  
  .send-btn {
    width: 2.75rem;
    height: 2.75rem;
  }

  .council-sidebar-item {
    min-height: 44px;
  }

  .file-item {
    min-height: 60px;
  }

  /* Prevent double-tap zoom */
  button,
  a,
  input,
  textarea,
  select {
    touch-action: manipulation;
  }
}

/* Scrollbar styling */
.chat-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 10px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
  background: var(--council-green);
  border-radius: 10px;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--council-green-hover);
}

/* Utility classes */
.hidden {
  display: none !important;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

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

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.p-1 {
  padding: 0.5rem;
}

.p-2 {
  padding: 1rem;
}

/* Footer Fixes */
.council-footer {
  width: 100%;
  background-color: var(--council-green) !important;
  color: white !important;
  text-align: center;
  padding: 1.5rem 0;
  margin-top: auto;
}
/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: 'Cairo', sans-serif;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--council-green);
    box-shadow: 0 0 0 3px rgba(21, 107, 104, 0.1);
}

.file-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 0.5rem;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-area:hover {
    border-color: var(--council-green);
    background: var(--gray-50);
}

.btn-primary {
    padding: 0.625rem 1.5rem;
    background: var(--council-green);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: 'Cairo', sans-serif;
}

.btn-primary:hover:not(:disabled) {
    background: var(--council-green-hover);
    transform: translateY(-1px);
}

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

.btn-secondary {
    padding: 0.625rem 1.5rem;
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: 'Cairo', sans-serif;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-upload {
    background: var(--council-gold) !important;
}

.btn-upload:hover {
    background: var(--council-gold-hover) !important;
}

.file-action-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    background: transparent;
}

.file-action-btn:hover {
    background: var(--gray-100);
}

.file-action-btn.edit {
    color: var(--council-green);
}

.file-action-btn.delete {
    color: #dc3545;
}

.file-action-btn svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Drag and drop highlight */
.file-upload-area.highlight {
    border-color: var(--council-green) !important;
    background-color: rgba(21, 107, 104, 0.05) !important;
}
