/* Application styles */

/* Custom RTL styles */
[dir="rtl"] .placeholder-ltr {
  direction: ltr;
  unicode-bidi: embed;
  display: inline-block;
  background-color: #f3f4f6;
  padding: 0 4px;
  border-radius: 4px;
  font-family: monospace;
}

/* Hide the original select when custom dropdown is active */
.custom-select.hidden-native {
  opacity: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
}

/* Custom dropdown container */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Custom dropdown button */
.custom-dropdown-button {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  line-height: 1.25rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-dropdown-button:hover {
  border-color: #9ca3af;
}

.custom-dropdown-button:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}

/* Custom dropdown chevron */
.custom-dropdown-chevron {
  width: 1rem;
  height: 1rem;
  color: #9ca3af;
  transition: transform 0.2s;
}

.custom-dropdown.open .custom-dropdown-chevron {
  transform: rotate(180deg);
}

/* Custom dropdown menu */
.custom-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.25rem;
}

.custom-dropdown-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border-bottom: 1px solid #f3f4f6;
}

.custom-dropdown-option:hover {
  background-color: #f3f4f6;
}

.custom-dropdown-option.selected {
  background-color: #eff6ff;
  color: #1d4ed8;
}

/* Remove default styling in Firefox */
select.custom-select::-moz-focus-inner {
  border: 0 !important;
}

/* Remove default styling in Chrome/Safari */
select.custom-select::-webkit-outer-spin-button,
select.custom-select::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

select.custom-select:hover {
  border-color: #9ca3af !important;
}

select.custom-select:focus {
  outline: none !important;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 1px #6366f1 !important;
}

/* Form focus styles */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Transition for interactive elements */
.btn,
.form-input,
.form-textarea,
.form-select,
a {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Semantic Color System */
:root {
  --color-primary: #4A90E2;
  --color-secondary: #B0AEE0;
  --color-text: #4A4A4A;
  --color-background: #ffffff;
  --color-success: #7ED6A4;
  --color-primary-hover: #357ABD;
  --color-secondary-hover: #9B98D8;
  --color-text-light: #6B7280;
  --color-border: #E5E7EB;
}

/* Semantic Button Styles */
.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-background);
  border: 1px solid var(--color-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-background);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

.btn-secondary {
  background-color: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: #F9FAFB;
  border-color: var(--color-primary);
  color: var(--color-text);
}

.btn-secondary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.btn-add {
  background-color: var(--color-background);
  color: var(--color-text-light);
  border: 2px dashed var(--color-border);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-add:hover {
  background-color: #F9FAFB;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-add:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* Semantic Form Styles */
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  color: var(--color-text);
  background-color: var(--color-background);
  transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-label {
  display: block;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.form-card {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-actions {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .form-actions {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
  }
  
  a {
    text-decoration: none;
    color: inherit;
  }
}

/* Custom Select Styling - Remove default appearance completely */
select.appearance-none,
select[class*="appearance-none"],
.appearance-none select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: none !important;
  background-color: white !important;
}

/* More specific selectors for form selects */
form select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: none !important;
}

/* For WebKit browsers */
select.appearance-none::-webkit-outer-spin-button,
select.appearance-none::-webkit-inner-spin-button,
form select::-webkit-outer-spin-button,
form select::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}

/* For Firefox */
select.appearance-none::-moz-focus-inner,
form select::-moz-focus-inner {
  border: 0 !important;
}

/* IE/Edge specific */
select.appearance-none::-ms-expand,
form select::-ms-expand {
  display: none !important;
}

/* Super specific rule for patient gender dropdown */
select[name="patient[gender]"],
#patient_gender {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: none !important;
  background-color: white !important;
}

/* Final Report Display Styles */

/* Final report content display styles */
.final-report-content h1 {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  margin-bottom: 1rem !important;
  margin-top: 1.5rem !important;
  line-height: 1.2 !important;
  color: #1f2937 !important; /* gray-800 */
}

.final-report-content h2 {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  margin-bottom: 0.75rem !important;
  margin-top: 1.25rem !important;
  line-height: 1.3 !important;
  color: #374151 !important; /* gray-700 */
}

.final-report-content h3 {
  font-size: 1.125rem !important;
  font-weight: 500 !important;
  margin-bottom: 0.5rem !important;
  margin-top: 1rem !important;
  line-height: 1.4 !important;
  color: #4b5563 !important; /* gray-600 */
}

/* RTL/LTR support */
.final-report-content p[dir="rtl"],
.final-report-content h1[dir="rtl"],
.final-report-content h2[dir="rtl"],
.final-report-content h3[dir="rtl"] {
  text-align: right;
  direction: rtl;
}

.final-report-content p[dir="ltr"],
.final-report-content h1[dir="ltr"],
.final-report-content h2[dir="ltr"],
.final-report-content h3[dir="ltr"] {
  text-align: left;
  direction: ltr;
}

.final-report-content p {
  margin-bottom: 1rem;
  color: #374151; /* gray-700 */
  line-height: 1.6;
}

.final-report-content p:last-child {
  margin-bottom: 0;
}

.final-report-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.final-report-content ul li {
  margin-bottom: 0.25rem;
}

.final-report-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.final-report-content ol li {
  margin-bottom: 0.25rem;
}

/* RTL support for lists - simple approach */
.final-report-content .rtl-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.final-report-content .rtl-list li {
  text-align: right;
  margin-bottom: 0.25rem;
  list-style: none;
}

.final-report-content li {
  color: #374151; /* gray-700 */
  line-height: 1.6;
}

.final-report-content a {
  color: #2563eb; /* blue-600 */
  text-decoration: underline;
}

.final-report-content a:hover {
  color: #1d4ed8; /* blue-700 */
}

.final-report-content strong {
  font-weight: 700;
}

.final-report-content em {
  font-style: italic;
}

.final-report-content u {
  text-decoration: underline;
}

.final-report-content blockquote {
  border-left: 4px solid #d1d5db; /* gray-300 */
  padding-left: 1rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  font-style: italic;
  color: #374151; /* gray-700 */
}

.final-report-content pre {
  background-color: #f3f4f6; /* gray-100 */
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.final-report-content code {
  background-color: #f3f4f6; /* gray-100 */
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  padding-top: 0.125rem;
  padding-bottom: 0.125rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.final-report-content hr {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border-top: 1px solid #d1d5db; /* gray-300 */
  border-bottom: 0;
  border-left: 0;
  border-right: 0;
}

/* Sliding menu overlay */
.menu-overlay {
  background-color: rgba(0, 0, 0, 0.3);
  position: fixed;
  inset: 0;
  z-index: 40;
}

/* Sortable drag and drop styles */
.sortable-ghost {
  opacity: 0.4;
  background: #f3f4f6;
  transform: rotate(2deg);
}

.sortable-chosen {
  cursor: grabbing !important;
}

.sortable-drag {
  opacity: 0.8;
  transform: rotate(-2deg);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.drag-handle {
  transition: all 0.2s ease;
}

/* Inline editable fields */
.form-card input[type="text"]:focus,
.form-card textarea:focus {
  background-color: rgba(59, 130, 246, 0.05);
  border-radius: 0.25rem;
  padding: 0.25rem;
  margin: -0.25rem;
}

/* Focused question card styling - Google Forms style */
.question-card.focused {
  border-left: 4px solid var(--color-primary);
  transition: border-left 0.2s ease;
}

.question-card:not(.focused) {
  border-left: 4px solid transparent;
  transition: border-left 0.2s ease;
}

/* Required checkbox styling - match brand color */
.question-card input[type="checkbox"] {
  accent-color: var(--color-primary);
  border-color: var(--color-primary);
}

.question-card input[type="checkbox"]:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.question-card input[type="checkbox"]:focus {
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
  border-color: var(--color-primary);
}

/* Remove default select styling for inline language selector */
select.border-0 {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2rem;
}


/* RTL Support for Todo Items */
[dir="rtl"] .todo-item {
  text-align: right;
}

[dir="rtl"] .editable-title,
[dir="rtl"] .editable-description {
  text-align: right;
}

/* Enhanced Sidebar Tabs */
.sidebar-tab {
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  position: relative;
}

.sidebar-tab:hover:not(.active) {
  background-color: rgba(59, 130, 246, 0.05) !important;
  border-bottom-color: rgba(59, 130, 246, 0.3) !important;
}

.sidebar-tab.active {
  background-color: #3B82F6 !important;
  border-bottom-color: #3B82F6 !important;
  color: white !important;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2) !important;
}

.sidebar-tab.active i {
  color: white !important;
}

.sidebar-tab.active span {
  color: white !important;
}

.sidebar-tab.active #tasks-count,
.sidebar-tab.active #notes-count {
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

.sidebar-tab:not(.active) #tasks-count,
.sidebar-tab:not(.active) #notes-count {
  background-color: #f3f4f6 !important;
  color: #6b7280 !important;
}

/* Sidebar tab content animations */
.sidebar-tab-content {
  animation: fadeIn 0.2s ease-in-out;
}

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

/* Enhanced file upload area */
.file-upload-area {
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.file-upload-area:hover {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #60a5fa;
}

.file-upload-area.drag-over {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #3b82f6;
  transform: scale(1.02);
}

/* Note indicators */
.note-indicator {
  transition: all 0.2s ease;
}

.note-indicator.saving {
  color: #f59e0b;
}

.note-indicator.saved {
  color: #10b981;
}

.note-indicator.error {
  color: #ef4444;
}

/* Enhanced scrollbars for sidebar content */
.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: #f8fafc;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

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

/* Compact sidebar view adjustments */
.sidebar-compact-view #notes-section {
  padding: 1rem;
}

.sidebar-compact-view #notes-section h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.sidebar-compact-view .btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.sidebar-compact-view .document-item {
  padding: 0.75rem;
}

.sidebar-compact-view .document-item h3 {
  font-size: 0.875rem;
}

.sidebar-compact-view .document-item p {
  font-size: 0.75rem;
}

.sidebar-compact-view .document-item .flex.items-center.text-xs {
  font-size: 0.6875rem;
}

.sidebar-compact-view .document-item .inline-flex {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

/* Hide large empty states in sidebar */
.sidebar-compact-view #empty-notes-state,
.sidebar-compact-view #empty-documents-state {
  padding: 2rem 1rem;
}

.sidebar-compact-view #empty-notes-state h3,
.sidebar-compact-view #empty-documents-state h3 {
  font-size: 0.875rem;
}

.sidebar-compact-view #empty-notes-state p,
.sidebar-compact-view #empty-documents-state p {
  font-size: 0.75rem;
}
