/* TLS eDiscovery Platform Styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tab Navigation */
.tab-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-button:hover {
  background: #f9fafb;
  color: #374151;
}

.tab-button.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #eff6ff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Filter Tags */
.filter-tag {
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.filter-tag:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.filter-tag.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.filter-tag .count {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0.25rem;
  font-size: 0.625rem;
  min-width: 1.25rem;
  text-align: center;
}

.filter-tag.active .count {
  background: rgba(255, 255, 255, 0.2);
}

/* Document Card */
.document-card {
  padding: 0.75rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.5rem;
}

.document-card:hover {
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.document-card.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.document-card .filename {
  font-weight: 600;
  font-size: 0.875rem;
  color: #111827;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-card .bates {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #2563eb;
  margin-bottom: 0.25rem;
}

.document-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.625rem;
  color: #6b7280;
}

.document-card .tags {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.document-card .tag {
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 600;
}

.document-card .tag.hot {
  background: #fee2e2;
  color: #991b1b;
}

.document-card .tag.privileged {
  background: #ede9fe;
  color: #5b21b6;
}

.document-card .tag.bad {
  background: #fef3c7;
  color: #92400e;
}

/* AI Analysis Cards */
.analysis-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.analysis-card .title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #111827;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.analysis-card .content {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #374151;
}

.confidence-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.confidence-badge.high {
  background: #dcfce7;
  color: #166534;
}

.confidence-badge.medium {
  background: #fef3c7;
  color: #92400e;
}

.confidence-badge.low {
  background: #fee2e2;
  color: #991b1b;
}

/* Note Card */
.note-card {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.note-card .note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.note-card .note-author {
  font-size: 0.75rem;
  font-weight: 600;
  color: #92400e;
}

.note-card .note-date {
  font-size: 0.625rem;
  color: #78716c;
}

.note-card .note-content {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #292524;
}

.note-card .note-page {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #2563eb;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #fde68a;
}

/* Classification Checkbox */
.classification-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.classification-item:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.classification-item.selected {
  background: #eff6ff;
  border-color: #2563eb;
}

.classification-item input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.75rem;
  cursor: pointer;
}

.classification-item .classification-info {
  flex: 1;
}

.classification-item .classification-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.classification-item .classification-desc {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* Loading Spinner */
.spinner {
  border: 2px solid #f3f4f6;
  border-top: 2px solid #2563eb;
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* PDF Viewer Canvas */
#pdf-canvas {
  max-width: 100%;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

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

.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===============================================
   MOBILE & TABLET RESPONSIVE STYLES
   =============================================== */

/* Lock orientation preference (CSS hint for supporting browsers) */
@media screen and (max-width: 1024px) {
  html {
    /* Suggest landscape on mobile for better UX */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* Force main container to be flexible */
  .h-screen.flex.flex-col {
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile */
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Force main content area to fill remaining space */
  .flex-1.flex.overflow-hidden {
    flex: 1 !important;
    overflow: hidden !important;
    display: flex !important;
  }
}

/* Mobile Portrait (Phone vertical) - Swipeable full-screen panels */
@media (max-width: 768px) and (orientation: portrait) {
  /* Force body to allow horizontal scroll */
  body {
    overflow-x: hidden !important;
    width: 100vw !important;
    touch-action: pan-x pan-y !important;
  }
  
  /* Override Tailwind flex classes to force horizontal scroll layout */
  /* Use very specific selector to override Tailwind */
  body .h-screen.flex.flex-col > .flex-1.flex.overflow-hidden,
  .flex-1.flex.overflow-hidden {
    flex-direction: row !important;
    display: flex !important;
    overflow-x: scroll !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    position: relative !important;
    width: 100vw !important;
    touch-action: pan-x !important;
  }
  
  /* Each panel is full-screen width and swipeable - VERY SPECIFIC SELECTORS */
  body .flex-1.flex.overflow-hidden > div,
  body .flex-1.flex.overflow-hidden > div:first-child,
  body .flex-1.flex.overflow-hidden > div:nth-child(2),
  body .flex-1.flex.overflow-hidden > div:last-child {
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    flex: 0 0 100vw !important;
    flex-shrink: 0 !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  /* Hide scrollbar but keep functionality */
  .flex-1.flex.overflow-hidden::-webkit-scrollbar {
    display: none;
  }
  
  .flex-1.flex.overflow-hidden {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  /* Panel Navigation Indicators */
  #panel-indicators {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex !important;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    z-index: 1000;
  }
  
  #panel-indicators .indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
  }
  
  #panel-indicators .indicator-dot.active {
    width: 24px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 1);
  }
  
  /* Panel Navigation Buttons */
  .panel-nav-button {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0.8;
  }
  
  .panel-nav-button:active {
    opacity: 1;
    transform: translateY(-50%) scale(0.95);
  }
  
  .panel-nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
  }
  
  #prev-panel-btn {
    left: 10px;
  }
  
  #next-panel-btn {
    right: 10px;
  }
  
  /* Header adjustments */
  header .flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  
  header .flex > div {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Hide logo on small mobile portrait */
  header img {
    height: 2rem;
  }
  
  /* Smaller text in header */
  header h1 {
    font-size: 1rem;
  }
  
  header p {
    font-size: 0.625rem;
  }
  
  /* Document cards - full width */
  .source-item {
    padding: 0.75rem !important;
  }
  
  /* Chat messages - better spacing */
  #chat-messages {
    padding: 1rem;
  }
  
  /* Input areas - larger touch targets */
  input, textarea, button, select {
    min-height: 44px; /* iOS recommended touch target */
  }
  
  /* Chat input area - MUCH LARGER */
  #chat-input {
    min-height: 80px !important;
    font-size: 18px !important; /* Prevents zoom on iOS and easier to read */
    line-height: 1.5 !important;
    padding: 1rem !important;
  }
  
  /* Make chat messages MUCH MORE readable with larger text */
  #chat-messages {
    font-size: 18px !important;
    line-height: 1.8 !important;
  }
  
  /* All chat message elements - AGGRESSIVE SIZING */
  .chat-message,
  #chat-messages .chat-message,
  #chat-messages p,
  #chat-messages div {
    font-size: 18px !important;
    line-height: 1.8 !important;
    padding: 1.25rem !important;
  }
  
  /* User messages */
  #chat-messages .bg-blue-600 {
    font-size: 18px !important;
  }
  
  /* AI messages */
  #chat-messages .bg-gray-100 {
    font-size: 18px !important;
  }
  
  /* Suggested questions - larger and easier to tap */
  .suggested-question {
    font-size: 16px !important;
    padding: 1rem 1.25rem !important;
    min-height: 44px !important;
  }
  
  /* Panel labels for better orientation - LARGER TEXT */
  body .flex-1.flex.overflow-hidden > div::before {
    content: attr(data-panel-name);
    display: block !important;
    padding: 16px 20px !important;
    background: #1f2937 !important;
    border-bottom: 2px solid #3b82f6 !important;
    font-weight: 700 !important;
    font-size: 18px !important;
    color: white !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    text-align: center !important;
  }
  
  body .flex-1.flex.overflow-hidden > div:first-child::before {
    content: "📚 Sources (Swipe Left →)" !important;
  }
  
  body .flex-1.flex.overflow-hidden > div:nth-child(2)::before {
    content: "💬 Chat (← Swipe →)" !important;
  }
  
  body .flex-1.flex.overflow-hidden > div:last-child::before {
    content: "📝 Notes (← Swipe Left)" !important;
  }
  
  /* Document list items - larger for readability */
  .document-card,
  .source-item {
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .document-card .filename {
    font-size: 16px !important;
  }
  
  .document-card .bates {
    font-size: 14px !important;
  }
  
  /* Search input - larger */
  #source-search {
    font-size: 16px !important;
    padding: 0.75rem 1rem !important;
    min-height: 44px !important;
  }
  
  /* All buttons - larger touch targets */
  button {
    min-height: 44px !important;
    font-size: 16px !important;
  }
  
  /* Send button in chat */
  #send-chat {
    min-width: 80px !important;
    min-height: 44px !important;
    font-size: 18px !important;
    padding: 0.75rem 1.5rem !important;
  }
}

/* Mobile Landscape (Phone horizontal) - Side-by-side panels */
@media (max-width: 1024px) and (orientation: landscape) {
  /* Optimize for landscape viewing */
  body {
    overflow: hidden;
  }
  
  /* Header - more compact */
  header {
    padding: 0.5rem 1rem !important;
  }
  
  header h1 {
    font-size: 1.125rem;
  }
  
  header img {
    height: 2.5rem;
  }
  
  /* Override Tailwind flex classes to force row layout */
  .flex-1.flex.overflow-hidden {
    flex-direction: row !important;
    display: flex !important;
  }
  
  /* Three panels - adjust widths for landscape */
  /* Left panel (sources) - MUCH NARROWER to give chat more space */
  .flex-1.flex.overflow-hidden > div:first-child {
    width: 15% !important;
    min-width: 140px !important;
    max-width: 180px !important;
    flex: none !important;
    height: 100% !important;
  }
  
  /* Center panel (chat) - MUCH WIDER - THIS IS THE PRIMARY WORKSPACE */
  .flex-1.flex.overflow-hidden > div:nth-child(2) {
    flex: 1 !important;
    width: auto !important;
    height: 100% !important;
    min-width: 500px !important;  /* Force minimum width for chat */
    max-width: none !important;
  }
  
  /* Right panel (notes/reports) - MUCH NARROWER to give chat more space */
  .flex-1.flex.overflow-hidden > div:last-child {
    width: 20% !important;
    min-width: 140px !important;
    max-width: 180px !important;
    flex: none !important;
    height: 100% !important;
  }
  
  /* Larger fonts for landscape mobile - READABLE TEXT */
  .document-card .filename {
    font-size: 14px !important;
  }
  
  .document-card .bates {
    font-size: 12px !important;
  }
  
  /* Chat messages - MUCH LARGER for readability */
  #chat-messages {
    font-size: 18px !important;
    line-height: 1.8 !important;
    padding: 1rem !important;
    /* Don't force height - let it grow naturally */
  }
  
  .chat-message,
  #chat-messages .chat-message,
  #chat-messages p,
  #chat-messages div {
    font-size: 18px !important;
    line-height: 1.8 !important;
    padding: 1rem !important;
  }
  
  /* User messages */
  #chat-messages .bg-blue-600 {
    font-size: 18px !important;
  }
  
  /* AI messages */
  #chat-messages .bg-gray-100 {
    font-size: 18px !important;
  }
  
  /* Chat input - larger */
  #chat-input {
    min-height: 60px !important;
    font-size: 18px !important;
    line-height: 1.5 !important;
    padding: 0.75rem !important;
  }
  
  /* Send button */
  #send-chat {
    min-width: 70px !important;
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 0.5rem 1rem !important;
  }
  
  /* Suggested questions - larger and easier to tap */
  .suggested-question {
    font-size: 15px !important;
    padding: 0.75rem 1rem !important;
    min-height: 44px !important;
  }
}

/* Tablet Portrait (iPad vertical) - Similar to mobile landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  /* Left panel - medium width */
  .flex.overflow-hidden > div:first-child {
    width: 30% !important;
    min-width: 280px !important;
    max-width: 350px !important;
  }
  
  /* Center panel - flexible */
  .flex.overflow-hidden > div:nth-child(2) {
    flex: 1 !important;
  }
  
  /* Right panel - medium width */
  .flex.overflow-hidden > div:last-child {
    width: 30% !important;
    min-width: 280px !important;
    max-width: 350px !important;
  }
}

/* Tablet Landscape (iPad horizontal) - Near desktop experience */
@media (min-width: 768px) and (max-width: 1280px) and (orientation: landscape) {
  /* Left panel */
  .flex.overflow-hidden > div:first-child {
    width: 22% !important;
    min-width: 280px !important;
    max-width: 320px !important;
  }
  
  /* Center panel */
  .flex.overflow-hidden > div:nth-child(2) {
    flex: 1 !important;
  }
  
  /* Right panel */
  .flex.overflow-hidden > div:last-child {
    width: 28% !important;
    min-width: 320px !important;
    max-width: 380px !important;
  }
}

/* Large Tablets and Small Laptops */
@media (min-width: 1024px) and (max-width: 1280px) {
  .w-80 {
    width: 16rem;
  }
  
  .w-96 {
    width: 20rem;
  }
}

/* Touch device optimizations (any device with touch) */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button, a, input[type="checkbox"], .source-checkbox {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .document-card:hover {
    border-color: #e5e7eb;
    box-shadow: none;
  }
  
  /* Show active/focus states instead */
  .document-card:active,
  button:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
  
  /* Prevent text selection issues on touch */
  .document-card,
  .source-item,
  button {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
    -webkit-touch-callout: none;
  }
  
  /* Better scrolling on iOS */
  .overflow-y-auto,
  .overflow-auto {
    -webkit-overflow-scrolling: touch;
  }
}

/* High DPI displays (Retina, etc.) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper fonts on high DPI */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* Thinner borders on Retina */
  .border {
    border-width: 0.5px;
  }
}

/* Safe area insets for devices with notches (iPhone X+) */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  header {
    padding-top: calc(0.75rem + env(safe-area-inset-top));
  }
}

/* Orientation-based layouts using data attributes (works better on iOS) */
body[data-orientation="landscape"] .flex-1.flex.overflow-hidden {
  flex-direction: row !important;
}

body[data-orientation="portrait"] .flex-1.flex.overflow-hidden {
  flex-direction: column !important;
}

/* Force specific layouts on small screens */
@media (max-width: 768px) {
  body[data-orientation="portrait"] .flex-1.flex.overflow-hidden > div {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 300px !important;
    flex: none !important;
  }
  
  body[data-orientation="landscape"] .flex-1.flex.overflow-hidden > div:first-child {
    width: 25% !important;
    min-width: 200px !important;
    flex: none !important;
    height: 100% !important;
  }
  
  body[data-orientation="landscape"] .flex-1.flex.overflow-hidden > div:nth-child(2) {
    flex: 1 !important;
    height: 100% !important;
  }
  
  body[data-orientation="landscape"] .flex-1.flex.overflow-hidden > div:last-child {
    width: 30% !important;
    min-width: 220px !important;
    flex: none !important;
    height: 100% !important;
  }
}

/* Dark mode support (optional, for system preference) */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here if desired */
  /* Currently using light mode only for legal document review */
}

/* Reduced motion support (accessibility) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  /* Hide UI elements when printing */
  header,
  .source-item input[type="checkbox"],
  button,
  .filter-tag {
    display: none !important;
  }
  
  /* Expand content for print */
  .flex.overflow-hidden > div {
    width: 100% !important;
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  
  /* Better print colors */
  body {
    background: white !important;
    color: black !important;
  }
}
