/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Design System - Amber Badge Colors (Tailwind purges these) */
.bg-amber-100 {
  background-color: #fef3c7 !important;
}
.text-amber-800 {
  color: #92400e !important;
}

/* Design System - Custom Button Colors */

/* Ensure button_to forms display inline in flex containers */
form.button_to {
  display: inline;
}

.btn-primary {
  background-color: #0ea5e9;
}
.btn-primary:hover {
  background-color: #0284c7;
}

.btn-success {
  background-color: #059669;
}
.btn-success:hover {
  background-color: #047857;
}

.btn-danger {
  background-color: #f43f5e;
}
.btn-danger:hover {
  background-color: #e11d48;
}

.btn-warning {
  background-color: #f59e0b;
}
.btn-warning:hover {
  background-color: #d97706;
}

/* Ghost Button - Transparent with border */
.btn-ghost {
  background-color: transparent;
  border: 2px solid #0ea5e9;
  color: #0ea5e9;
}
.btn-ghost:hover {
  background-color: rgba(14, 165, 233, 0.1);
  border-color: #0284c7;
  color: #0284c7;
}

/* Collapsible Table of Contents */
.toc-sidebar {
  width: 280px;
  transition: width 0.3s ease-in-out, opacity 0.3s ease-in-out;
  position: relative;
}

.toc-sidebar.toc-collapsed {
  width: 48px;
  overflow: hidden;
}

.toc-sidebar.toc-collapsed .toc-content {
  opacity: 0;
  pointer-events: none;
}

/* TOC Scrollbar Styling */
.toc-sidebar::-webkit-scrollbar {
  width: 6px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* TOC Toggle Button */
.toc-toggle {
  transition: all 0.2s ease-in-out;
}

.toc-toggle:hover {
  background-color: #eff6ff;
  color: #0ea5e9;
}

/* Responsive: Hide TOC on mobile */
@media (max-width: 768px) {
  .toc-sidebar {
    display: none;
  }
}

/* Contenteditable Editing State - Subtle Glow Effect */
.editing-active .editing-glow-container {
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.15),
    0 0 20px rgba(59, 130, 246, 0.1),
    0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Remove default focus outline on contenteditable */
[contenteditable="true"]:focus {
  outline: none;
}

/* ============================================
   Table Styles for Contract Documents
   ============================================ */

/* Base table styling */
.prose table,
.contract-content table,
table.contract-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

/* Table header */
.prose table thead,
.contract-content table thead,
table.contract-table thead {
  background-color: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
}

.prose table th,
.contract-content table th,
table.contract-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e5e7eb;
}

/* Table cells */
.prose table td,
.contract-content table td,
table.contract-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  color: #4b5563;
  vertical-align: top;
}

/* Alternating row colors */
.prose table tbody tr:nth-child(even),
.contract-content table tbody tr:nth-child(even),
table.contract-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

/* Row hover effect */
.prose table tbody tr:hover,
.contract-content table tbody tr:hover,
table.contract-table tbody tr:hover {
  background-color: #f3f4f6;
}

/* Last row no border */
.prose table tbody tr:last-child td,
.contract-content table tbody tr:last-child td,
table.contract-table tbody tr:last-child td {
  border-bottom: none;
}

/* Compact table variant */
table.table-compact th,
table.table-compact td {
  padding: 8px 12px;
  font-size: 13px;
}

/* Bordered table variant */
table.table-bordered th,
table.table-bordered td {
  border: 1px solid #e5e7eb;
}

/* Table caption */
.prose table caption,
.contract-content table caption,
table.contract-table caption {
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  text-align: left;
  caption-side: top;
}

/* Responsive table wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
}

/* Print styles for tables */
@media print {
  .prose table,
  .contract-content table,
  table.contract-table {
    page-break-inside: avoid;
  }

  .prose table th,
  .contract-content table th,
  table.contract-table th {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ============================================
   Unified Sidebar Design System
   ============================================ */

/* Sidebar base styles */
.sidebar-panel {
  background-color: white;
  border-right: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

/* Sidebar scrollbar styling */
.sidebar-panel::-webkit-scrollbar,
.risks-sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar-panel::-webkit-scrollbar-track,
.risks-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-panel::-webkit-scrollbar-thumb,
.risks-sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.sidebar-panel::-webkit-scrollbar-thumb:hover,
.risks-sidebar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Form input focus states - unified */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.3);
  border-color: #0ea5e9;
}

/* Sidebar section headers */
.sidebar-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* Risks sidebar specific styling */
.risks-sidebar {
  border-radius: 0.5rem;
  overflow: hidden;
}

/* Custom min-width utility */
.min-w-\[320px\] {
  min-width: 320px;
}

/* ============================================
   Risk Card Hover & Animation Styles
   Replaces inline JS event handlers (XSS risk)
   ============================================ */

/* Risk card hover effect */
.risk-card-hoverable {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.risk-card-hoverable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Risk card button hover states */
.risk-btn-show {
  transition: background 0.2s ease;
}

.risk-btn-show:hover {
  background: #f9fafb !important;
}

.risk-btn-fix {
  transition: background 0.2s ease;
}

.risk-btn-fix:hover {
  background: #059669 !important;
}

.risk-btn-generate {
  transition: background 0.2s ease;
}

.risk-btn-generate:hover {
  background: #d97706 !important;
}

.risk-btn-ghost {
  transition: color 0.2s ease;
}

.risk-btn-ghost:hover {
  color: #374151 !important;
}

/* Risk card active state */
.risk-card-active,
.risk-card-v2--active {
  box-shadow: 0 0 0 2px #3b82f6, 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Risk card fixed state */
.risk-card--fixed {
  opacity: 0.6;
}

/* Risk card expanded state */
.risk-card-expanded {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Expansion animation */
.expansion-animate {
  animation: expandIn 0.2s ease-out;
}

@keyframes expandIn {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 200px;
  }
}
