/**
 * Main Application Styles
 * Tailwind CSS customizations and utility classes
 *
 * COLOR THEME:
 * - Primary (Indigo): #4F46E5 (Light) / #818CF8 (Dark Hover)
 * - Primary Dark: #4338CA (Light Hover) / #6366F1 (Dark)
 * - Destructive (Red): #EF4444 (Logout Button)
 * - Text: #1F2937 (Light) / #E5E7EB (Dark)
 * - Background: #FFFFFF (Light) / #1A2332 (Dark)
 * - Borders: #D1D5DB (Light) / #4A5568 (Dark)
 *
 * CONSISTENCY RULES:
 * 1. All buttons use indigo primary color (#4F46E5)
 * 2. Hover states: darker shade with shadow + lift animation
 * 3. Active states: darker shade with reduced shadow + no lift
 * 4. Form inputs: high contrast text on light/dark backgrounds
 * 5. Labels: bold, high contrast in both modes
 * 6. Focus states: indigo border + shadow ring
 * 7. Transitions: 0.2s ease for smooth effects
 * 8. Logout button: distinctive red (#EF4444) with same hover mechanics
 */

/* Scrollbar Styling */
::-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;
}

/* CodeMirror Custom Styling - Light Mode */
.CodeMirror {
  border: 1px solid #d1d5db !important;
  border-radius: 0.5rem !important;
  font-family: 'Courier New', monospace !important;
  font-size: 14px !important;
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

.CodeMirror-gutters {
  background-color: #f9fafb !important;
  border-right: 1px solid #e5e7eb !important;
}

.CodeMirror-linenumber {
  padding: 0 8px !important;
  color: #9ca3af !important;
}

.CodeMirror.CodeMirror-focused {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

/* CodeMirror cursor and selection - Light Mode */
.CodeMirror-cursor {
  border-left-color: #1f2937 !important;
}

.CodeMirror-selected {
  background-color: #c7d2fe !important;
}

/* CodeMirror Custom Styling - Dark Mode */
html.dark .CodeMirror {
  background-color: #1a2332 !important;
  color: #e5e7eb !important;
  border-color: #4a5568 !important;
}

html.dark .CodeMirror-gutters {
  background-color: #0f1419 !important;
  border-right-color: #4a5568 !important;
}

html.dark .CodeMirror-linenumber {
  color: #6b7280 !important;
}

html.dark .CodeMirror.CodeMirror-focused {
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2) !important;
}

html.dark .CodeMirror-cursor {
  border-left-color: #e5e7eb !important;
}

html.dark .CodeMirror-selected {
  background-color: #4338ca !important;
}

/* Input Field Focus Styling */
input:focus,
textarea:focus,
select:focus {
  outline: none;
}

/* Smooth Transitions - Modern Feel */
* {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body {
  scroll-behavior: smooth;
}

/* ===== UNIFIED BUTTON SYSTEM ===== */
/* ALL BUTTONS inherit these base styles */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
}

button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Default button styling - Light Mode: White with Indigo Border */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn-primary,
.bg-indigo-600:not(:disabled),
.bg-green-600:not(:disabled),
.bg-blue-600:not(:disabled),
.bg-gray-700:not(:disabled) {
  background-color: #ffffff;
  color: #4F46E5;
  border: 2px solid #4F46E5;
}

button:hover:not(:disabled),
input[type="button"]:hover:not(:disabled),
input[type="submit"]:hover:not(:disabled),
input[type="reset"]:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.bg-indigo-600:hover:not(:disabled),
.bg-green-600:hover:not(:disabled),
.bg-blue-600:hover:not(:disabled),
.bg-gray-700:hover:not(:disabled) {
  background-color: #4F46E5;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transform: translateY(-2px);
}

button:active:not(:disabled),
input[type="button"]:active:not(:disabled),
input[type="submit"]:active:not(:disabled),
input[type="reset"]:active:not(:disabled),
.btn-primary:active:not(:disabled) {
  background-color: #4338CA;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
  transform: translateY(0);
}

/* Dark mode - Indigo Primary (lighter on hover for visibility) */
html.dark button:not(:disabled),
html.dark input[type="button"]:not(:disabled),
html.dark input[type="submit"]:not(:disabled),
html.dark input[type="reset"]:not(:disabled),
html.dark .btn-primary:not(:disabled),
html.dark .bg-indigo-600:not(:disabled),
html.dark .bg-green-600:not(:disabled),
html.dark .bg-blue-600:not(:disabled),
html.dark .bg-gray-700:not(:disabled) {
  background-color: #4F46E5;
  color: #ffffff;
}

html.dark button:hover:not(:disabled),
html.dark input[type="button"]:hover:not(:disabled),
html.dark input[type="submit"]:hover:not(:disabled),
html.dark input[type="reset"]:hover:not(:disabled),
html.dark .btn-primary:hover:not(:disabled),
html.dark .bg-indigo-600:hover:not(:disabled),
html.dark .bg-green-600:hover:not(:disabled),
html.dark .bg-blue-600:hover:not(:disabled),
html.dark .bg-gray-700:hover:not(:disabled) {
  background-color: #6366F1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

html.dark button:active:not(:disabled),
html.dark input[type="button"]:active:not(:disabled),
html.dark input[type="submit"]:active:not(:disabled),
html.dark input[type="reset"]:active:not(:disabled),
html.dark .btn-primary:active:not(:disabled),
html.dark .bg-indigo-600:active:not(:disabled) {
  background-color: #4338CA;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
  transform: translateY(0);
}

/* Red buttons (logout, delete) - Light Mode: White with Red Border */
.bg-red-500:not(:disabled),
.bg-red-600:not(:disabled) {
  background-color: #ffffff;
  color: #EF4444;
  border: 2px solid #EF4444;
}

.bg-red-500:hover:not(:disabled),
.bg-red-600:hover:not(:disabled) {
  background-color: #EF4444;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

.bg-red-500:active:not(:disabled),
.bg-red-600:active:not(:disabled) {
  background-color: #DC2626;
  color: #ffffff;
  border-color: #DC2626;
  transform: translateY(0);
}

html.dark .bg-red-500:not(:disabled),
html.dark .bg-red-600:not(:disabled) {
  background-color: #DC2626 !important;
  color: #ffffff !important;
  border-color: #DC2626 !important;
}

html.dark .bg-red-500:hover:not(:disabled),
html.dark .bg-red-600:hover:not(:disabled) {
  background-color: #EF4444 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5) !important;
  transform: translateY(-2px);
}

/* Secondary/Border buttons - Light Mode: White with Indigo Border */
.btn-secondary,
.bg-gray-200:not(:disabled),
.border-indigo-600:not(:disabled),
.border-gray-300:not(:disabled),
.border-red-300:not(:disabled) {
  background-color: #ffffff;
  color: #4F46E5;
  border: 2px solid #4F46E5;
}

.btn-secondary:hover:not(:disabled),
.bg-gray-200:hover:not(:disabled),
.border-indigo-600:hover:not(:disabled),
.border-gray-300:hover:not(:disabled),
.border-red-300:hover:not(:disabled) {
  background-color: #4F46E5;
  border-color: #4F46E5;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transform: translateY(-2px);
}

.btn-secondary:active:not(:disabled) {
  background-color: #4338CA;
  transform: translateY(0);
}

html.dark .btn-secondary:not(:disabled),
html.dark .bg-gray-200:not(:disabled),
html.dark .border-indigo-600:not(:disabled),
html.dark .border-gray-300:not(:disabled),
html.dark .border-red-300:not(:disabled) {
  background-color: #4F46E5;
  color: #ffffff;
  border-color: #6366F1;
}

html.dark .btn-secondary:hover:not(:disabled),
html.dark .bg-gray-200:hover:not(:disabled),
html.dark .border-indigo-600:hover:not(:disabled),
html.dark .border-gray-300:hover:not(:disabled),
html.dark .border-red-300:hover:not(:disabled) {
  background-color: #6366F1;
  border-color: #818CF8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

html.dark .btn-secondary:active:not(:disabled) {
  background-color: #4338CA;
  transform: translateY(0);
}

/* Loading Spinner */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Table Row Hover */
tbody tr {
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: #f9fafb;
}

/* Modal Backdrop */
#queryModal::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

/* Notification Animations */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

#errorNotification,
#successNotification {
  animation: slideIn 0.3s ease-out;
}

/* Code Block Styling */
code {
  font-family: 'Courier New', monospace;
  background-color: #f3f4f6;
  padding: 2px 4px;
  border-radius: 3px;
}

pre {
  overflow-x: auto;
  background-color: #1f2937;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

/* Dark Mode Support */
html.dark {
  color-scheme: dark;
  background-color: #0f1419;
}

html.dark body {
  background-color: #0f1419;
  color: #e5e7eb;
}

/* Dark mode heading colors for contrast */
html.dark h1,
html.dark h2,
html.dark h3 {
  color: #6366f1 !important;
}

html.dark h4,
html.dark h5,
html.dark h6 {
  color: #e5e7eb !important;
}

/* Light and dark mode larger font sizes use blue theme */
.text-3xl {
  color: #4f46e5 !important;
}

.text-2xl {
  color: #4f46e5 !important;
}

.text-xl {
  color: #4f46e5 !important;
}

.text-lg {
  color: #4f46e5 !important;
}

html.dark .text-3xl {
  color: #6366f1 !important;
}

html.dark .text-2xl {
  color: #6366f1 !important;
}

html.dark .text-xl {
  color: #6366f1 !important;
}

html.dark .text-lg {
  color: #6366f1 !important;
}

/* Ensure text-gray-900 becomes light in dark mode (for normal sized text) */
html.dark .text-gray-900 {
  color: #e5e7eb !important;
}

html.dark .text-red-900 {
  color: #fecaca !important;
}

/* Dark mode card backgrounds */
html.dark .bg-white {
  background-color: #1a2332;
  color: #e5e7eb;
}

html.dark .bg-gray-50 {
  background-color: #0f1419;
}

html.dark .bg-gray-100 {
  background-color: #1a2332;
}

html.dark .bg-gray-200 {
  background-color: #2d3748;
}

html.dark .bg-gray-300 {
  background-color: #4a5568;
}

html.dark .bg-gray-800 {
  background-color: #1a2332;
}

/* Dark mode text colors */
html.dark .text-gray-900 {
  color: #e5e7eb;
}

html.dark .text-gray-700 {
  color: #cbd5e0;
}

html.dark .text-gray-600 {
  color: #a0aec0;
}

html.dark .text-gray-500 {
  color: #718096;
}

html.dark .text-gray-400 {
  color: #4a5568;
}

html.dark .text-gray-300 {
  color: #2d3748;
}

/* Dark mode form inputs - Enhanced contrast */
html.dark input[type='text'],
html.dark input[type='email'],
html.dark input[type='password'],
html.dark input[type='number'],
html.dark input[type='date'],
html.dark select,
html.dark textarea {
  background-color: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #4a5568;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

html.dark input[type='text']:hover,
html.dark input[type='email']:hover,
html.dark input[type='password']:hover,
html.dark input[type='number']:hover,
html.dark input[type='date']:hover,
html.dark textarea:hover {
  background-color: #2d3748 !important;
  color: #e5e7eb !important;
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.1);
}

/* ===== DROPDOWN/SELECT DARK MODE STYLING ===== */
/* Override Tailwind dark: classes to keep backgrounds consistent */

html.dark select,
html.dark select:hover,
html.dark select:focus,
html.dark select:active,
html.dark select[class*="bg-"],
html.dark select[class*="dark:"],
.dark select,
.dark select:hover,
.dark select:focus,
.dark select:active {
  background-color: #1a2332 !important;
  color: #e5e7eb !important;
}

html.dark select:focus,
.dark select:focus {
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2) !important;
  outline: none !important;
}

html.dark select:hover,
.dark select:hover {
  border-color: #818cf8 !important;
}

/* Dark mode option elements */
html.dark select option,
.dark select option {
  background-color: #1a2332 !important;
  color: #e5e7eb !important;
  padding: 8px 12px;
}

html.dark select option:hover,
html.dark select option:focus,
html.dark select option:checked,
html.dark select option:active,
.dark select option:hover,
.dark select option:checked {
  background-color: #2d3748 !important;
  color: #e5e7eb !important;
}

html.dark input[type='text']:focus,
html.dark input[type='email']:focus,
html.dark input[type='password']:focus,
html.dark input[type='number']:focus,
html.dark input[type='date']:focus,
html.dark textarea:focus {
  background-color: #2d3748 !important;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
  color: #f3f4f6 !important;
  outline: none;
}

/* Light mode placeholder text */
input::placeholder,
textarea::placeholder {
  color: #6b7280;
}

select {
  color: #1f2937;
}

/* Dark mode placeholder text - High contrast */
html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #9ca3af;
}

html.dark select {
  color: #e5e7eb;
}

/* Label Styling - High Contrast */
label {
  color: #1f2937;
  font-weight: 500;
}

html.dark label {
  color: #f3f4f6;
  font-weight: 500;
}

/* Dark mode button hover states - Consistent with light mode */
html.dark button:not(:disabled):hover {
  color: #ffffff !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

html.dark .bg-indigo-600:not(:disabled):hover {
  background-color: #6366f1 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4) !important;
}

html.dark .bg-red-500:not(:disabled):hover {
  background-color: #ef4444 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

/* Dark mode buttons - Blue theme */
html.dark .bg-indigo-600:not(:disabled),
html.dark .bg-green-600:not(:disabled),
html.dark .bg-blue-600:not(:disabled) {
  background-color: #6366f1 !important;
  color: #ffffff !important;
}

html.dark .bg-indigo-600:not(:disabled):hover,
html.dark .bg-green-600:not(:disabled):hover,
html.dark .bg-blue-600:not(:disabled):hover {
  background-color: #818cf8 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(129, 140, 248, 0.4) !important;
}

html.dark .bg-red-600:not(:disabled):hover,
html.dark .bg-red-500:not(:disabled):hover {
  background-color: #ef4444 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

/* Dark mode secondary buttons - Blue theme */
html.dark .bg-gray-200:not(:disabled) {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
}

html.dark .bg-gray-200:not(:disabled):hover {
  background-color: #6366f1 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4) !important;
}

html.dark .bg-gray-700:not(:disabled) {
  background-color: #6366f1 !important;
  color: #ffffff !important;
}

html.dark .bg-gray-700:not(:disabled):hover {
  background-color: #818cf8 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(129, 140, 248, 0.4) !important;
}

/* Dark mode border buttons - Blue theme */
html.dark .border-indigo-600:not(:disabled),
html.dark .border-gray-300:not(:disabled),
html.dark .border-red-300:not(:disabled) {
  border-color: #818cf8 !important;
  color: #818cf8 !important;
  background-color: transparent;
}

html.dark .border-indigo-600:not(:disabled):hover,
html.dark .border-gray-300:not(:disabled):hover,
html.dark .border-red-300:not(:disabled):hover {
  background-color: rgba(99, 102, 241, 0.1) !important;
  border-color: #818cf8 !important;
  color: #c7d2fe !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}

/* Dark mode table styling */
html.dark table {
  background-color: #1a2332;
  color: #e5e7eb;
}

html.dark thead {
  background-color: #2d3748;
  color: #e5e7eb;
}

html.dark tbody tr {
  border-color: #2d3748;
}

html.dark tbody tr:hover {
  background-color: #2d3748;
}

html.dark td, 
html.dark th {
  border-color: #2d3748;
}

/* Dark mode scrollbar */
html.dark ::-webkit-scrollbar-track {
  background: #1a2332;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #4a5568;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

/* Light mode scrollbar */
::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive Typography */
@media (max-width: 640px) {
  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }
}

/* SQL Keyword Highlighting (for manual highlights) */
.sql-keyword {
  color: #6366f1;
  font-weight: 600;
}

.sql-function {
  color: #ec4899;
}

.sql-comment {
  color: #6b7280;
}

/* Custom Checkbox & Radio Styling */
input[type='checkbox'],
input[type='radio'] {
  cursor: pointer;
  accent-color: #4F46E5;
  width: 18px;
  height: 18px;
  transition: all 0.2s ease;
}

input[type='checkbox']:hover,
input[type='radio']:hover {
  accent-color: #4338CA;
}

html.dark input[type='checkbox'],
html.dark input[type='radio'] {
  accent-color: #818CF8;
}

html.dark input[type='checkbox']:hover,
html.dark input[type='radio']:hover {
  accent-color: #A5B4FC;
}

/* Form Input Styling - Light Mode (High Contrast) */
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
textarea {
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  background-color: #ffffff !important;
  color: #1f2937;
  border: 1px solid #d1d5db;
}

input[type='text']:hover,
input[type='email']:hover,
input[type='password']:hover,
input[type='number']:hover,
input[type='date']:hover,
textarea:hover {
  border-color: #4f46e5;
  background-color: #ffffff !important;
  color: #4f46e5 !important;
}

/* ===== DROPDOWN/SELECT UNIFIED STYLING ===== */
/* Override Tailwind and inline styles to keep backgrounds consistent */

/* Light mode - all states */
select,
select:hover,
select:focus,
select:active,
select[class*="bg-"],
select[class*="dark:"] {
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

select:focus {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
  outline: none !important;
}

select:hover {
  border-color: #4f46e5 !important;
}

/* Light mode option elements */
select option {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  padding: 8px 12px;
}

select option:hover,
select option:focus,
select option:checked,
select option:active {
  background-color: #f3f4f6 !important;
  color: #1f2937 !important;
}

input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
input[type='number']:focus,
input[type='date']:focus,
textarea:focus {
  border-color: #4f46e5;
  background-color: #ffffff !important;
  color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

/* Disabled State */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Logout Button - Light Mode: White with Red Border */
#logoutBtn {
  background-color: #ffffff;
  color: #EF4444;
  transition: all 0.2s ease-in-out;
  border: 2px solid #EF4444;
  font-weight: 600;
  cursor: pointer;
}

#logoutBtn:hover {
  background-color: #EF4444;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

#logoutBtn:active {
  background-color: #DC2626;
  color: #ffffff;
  border-color: #DC2626;
  transform: translateY(0);
}

/* Dark mode: same as light mode - white with red text/border */
html.dark #logoutBtn {
  background-color: #ffffff !important;
  color: #EF4444 !important;
  border: 2px solid #EF4444 !important;
}

html.dark #logoutBtn:hover {
  background-color: #EF4444 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
  transform: translateY(-2px);
}

html.dark #logoutBtn:active {
  background-color: #DC2626 !important;
  color: #ffffff !important;
  border-color: #DC2626 !important;
  transform: translateY(0);
}

/* Cloudflare Turnstile CAPTCHA Styling */
#captchaContainer {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

#captchaContainer iframe {
  border-radius: 0.375rem;
}

/* Dark mode CAPTCHA - Turnstile auto-detects via prefers-color-scheme */
html.dark #captchaContainer {
  filter: invert(0.93);
}

/* Link Styling - Modern & Professional (LINKS ONLY, NOT BUTTONS) */
a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"]) {
  color: #4f46e5;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
}

a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"]):hover {
  color: #4338ca;
}

a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"])::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #4f46e5;
  transition: width 0.3s ease;
}

a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"]):hover::after {
  width: 100%;
}

html.dark a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"]) {
  color: #818cf8;
}

html.dark a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"]):hover {
  color: #a5b4fc;
}

html.dark a:not(button):not(input):not(.btn-primary):not(.btn-secondary):not([class*="btn-"])::after {
  background-color: #818cf8;
}

/* Success & Error States - Modern Design */
.error-border {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
  background-color: #fef2f2;
}

html.dark .error-border {
  background-color: rgba(239, 68, 68, 0.1);
}

.success-border {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15) !important;
  background-color: #f0fdf4;
}

html.dark .success-border {
  background-color: rgba(34, 197, 94, 0.1);
}

/* Modern Card Styling */
.bg-white,
.bg-gray-50,
.card,
[class*="rounded-lg"] {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.bg-white:hover,
.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}

html.dark .bg-white,
html.dark .bg-gray-50,
html.dark .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

html.dark .bg-white:hover,
html.dark .card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Table Styling - Modern & Professional */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: #ffffff;
  border-radius: 0.5rem;
  overflow: hidden;
}

thead {
  background-color: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
}

thead th {
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  color: #1f2937;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  background-color: #f9fafb;
}

tbody td {
  padding: 0.75rem 1rem;
  color: #374151;
}

html.dark table {
  background-color: #1a2332;
}

html.dark thead {
  background-color: #2d3748;
  border-bottom-color: #4a5568;
}

html.dark thead th {
  color: #e5e7eb;
}

html.dark tbody tr {
  border-bottom-color: #2d3748;
}

html.dark tbody tr:hover {
  background-color: #2d3748;
}

html.dark tbody td {
  color: #cbd5e0;
}

/* Modern Form Group Styling */
.form-group,
[class*="space-y"] > * {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.375rem;
}

/* Modern Header Styling */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font-size: 2.25rem;
  font-weight: 800;
}

h2 {
  font-size: 1.875rem;
  font-weight: 700;
}

h3 {
  font-size: 1.5rem;
  font-weight: 700;
}

h4 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Improved Typography */
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;
  line-height: 1.6;
}

p {
  color: #4b5563;
  font-size: 1rem;
}

html.dark p {
  color: #cbd5e0;
}

/* Container Queries */
@supports (container-type: inline-size) {
  .query-container {
    container-type: inline-size;
  }

  @container (min-width: 400px) {
    .query-responsive {
      display: grid;
      grid-template-columns: 1fr 1fr;
    }
  }
}

/* Modern Navigation Bar */
nav {
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

html.dark nav {
  background-color: #1a2332;
  border-bottom-color: #2d3748;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

nav a {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  position: relative;
}

nav a:not(:last-child) {
  margin-right: 0.5rem;
}

nav a:hover {
  background-color: #f3f4f6;
}

html.dark nav a:hover {
  background-color: #2d3748;
}

/* Theme Toggle Button - Modern Design */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 0.375rem;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #1f2937;
}

html.dark .theme-toggle {
  border-color: #4a5568;
  background-color: #2d3748;
  color: #e5e7eb;
}

.theme-toggle:hover {
  background-color: #e5e7eb;
  border-color: #d1d5db;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

html.dark .theme-toggle:hover {
  background-color: #374151;
  border-color: #4a5568;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: #1f2937;
  transition: all 0.3s ease;
}

html.dark .theme-toggle svg {
  color: #f3f4f6;
}

/* Schema Table Expand/Collapse */
.tableColumns {
  overflow: hidden;
  max-height: 0;
  opacity: 1;
  transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.tableColumns:not(.hidden) {
  max-height: 500px;
}

.tableColumns.hidden {
  display: none;
}

/* Chevron icon animation */
[data-chevron] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease-out;
}

/* Table toggle header styling */
[data-table-toggle] {
  user-select: none;
}

[data-table-toggle]:active {
  background-color: #f3f4f6;
}

html.dark [data-table-toggle]:active {
  background-color: #2d3748;
}

/* Dark mode styling for table cards */
html.dark [data-table-toggle] {
  background-color: #1a2332;
  border-color: #2d3748;
}

html.dark [data-table-toggle]:hover {
  background-color: #2d3748;
}

html.dark .tableColumns {
  background-color: #0f1419;
  border-color: #2d3748;
}

html.dark [data-columns] {
  background-color: #0f1419;
}

/* Font styling for column details */
.font-mono {
  font-family: 'Courier New', monospace;
}

/* ===== DELETE ACCOUNT CARD STYLING ===== */
/* Keep same appearance in both light and dark modes */

/* Title - use indigo color like other titles */
.delete-account-title {
  color: #4f46e5 !important;
  font-weight: bold;
}

html.dark .delete-account-title {
  color: #6366f1 !important;
  font-weight: bold;
}

/* Delete Account card - force light mode appearance in dark mode */
html.dark .bg-red-50 {
  background-color: #fef2f2 !important;
}

html.dark .border-red-200 {
  border-color: #fecaca !important;
}

html.dark .text-red-700 {
  color: #b91c1c !important;
}

html.dark .text-red-900 {
  color: #7f1d1d !important;
}

/* Delete Account button - match Logout button styling */
/* Light mode: white with red border/text, hover: red with white text */
#deleteAccountBtn {
  background-color: #ffffff !important;
  color: #EF4444 !important;
  border: 2px solid #EF4444 !important;
}

#deleteAccountBtn:hover {
  background-color: #EF4444 !important;
  color: #ffffff !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

#deleteAccountBtn:active {
  background-color: #DC2626 !important;
  color: #ffffff !important;
  border-color: #DC2626 !important;
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2) !important;
}

/* Dark mode: same as light mode for this card */
html.dark #deleteAccountBtn {
  background-color: #ffffff !important;
  color: #EF4444 !important;
  border: 2px solid #EF4444 !important;
}

html.dark #deleteAccountBtn:hover {
  background-color: #EF4444 !important;
  color: #ffffff !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

html.dark #deleteAccountBtn:active {
  background-color: #DC2626 !important;
  color: #ffffff !important;
  border-color: #DC2626 !important;
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2) !important;
}

/* ===== NOTE: All button styles consolidated in UNIFIED BUTTON SYSTEM above (lines 72-260) ===== */
/* Do not add button styles here - use the unified system instead */

.theme-toggle .sun-icon {
  display: block;
}

.theme-toggle .moon-icon {
  display: none;
}

.dark .theme-toggle .sun-icon {
  display: none;
}

.dark .theme-toggle .moon-icon {
  display: block;
}

/* ===== DROPDOWN DIRECTION - FORCE DOWNWARD ===== */
/* Ensure dropdowns have space to open downward */
select {
  /* Prevent browser from flipping dropdown direction */
  position: relative;
}

/* Ensure parent containers don't constrain dropdown direction */
.bg-white,
.bg-gray-50,
[class*="rounded-lg"],
.space-y-6 > *,
.space-y-4 > *,
.space-y-2 > * {
  overflow: visible !important;
}

/* Add padding to form containers to give browsers more space below selects */
form,
.p-4,
.p-6,
.p-8 {
  padding-bottom: 1rem;
}

/* Ensure select containers have proper stacking context */
select,
[class*="select"] {
  z-index: 10;
}

/* When select is focused/active, raise z-index for dropdown visibility */
select:focus,
select:active {
  z-index: 50;
}

/* Ensure modal and card containers don't clip dropdowns */
[class*="shadow"],
[class*="rounded"] {
  overflow: visible !important;
}

/* Exception: Keep overflow hidden/auto where needed for scrolling */
.overflow-x-auto {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

.overflow-y-auto {
  overflow-y: auto !important;
}

.max-h-96 {
  overflow-y: auto !important;
}

#schemaTree {
  overflow-y: auto !important;
}

#resultsTable {
  overflow-x: auto !important;
}

/* Table containers need their overflow for scrolling */
table {
  overflow: visible;
}

.overflow-hidden {
  overflow: hidden !important;
}