/* LegalDocs Pro - Custom Styles */

/* NOTE: CSS variables (--primary-color, etc.) are set dynamically in base.html */
/* from the tenant's brand profile. Do NOT set :root variables here as they */
/* would override the dynamic values from Django templates. */

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Focus styles */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Alpine.js cloaking */
[x-cloak] {
    display: none !important;
}

/* Form styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
select,
textarea {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Color picker */
input[type="color"] {
    padding: 0;
    border: none;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: 1px solid #d1d5db;
}

/* Checkbox and radio */
input[type="checkbox"],
input[type="radio"] {
    color: var(--primary-color);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Button styles - Brand colors */
.btn-primary {
    background-color: var(--button-color, var(--primary-color));
    color: var(--button-text-color, white);
    transition: background-color 0.15s ease-in-out, filter 0.15s ease-in-out;
}

.btn-primary:hover {
    filter: brightness(0.9);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    transition: background-color 0.15s ease-in-out, filter 0.15s ease-in-out;
}

.btn-secondary:hover {
    filter: brightness(0.9);
}

.btn-accent {
    background-color: var(--accent-color);
    color: white;
    transition: background-color 0.15s ease-in-out, filter 0.15s ease-in-out;
}

.btn-accent:hover {
    filter: brightness(0.9);
}

/* Override blue Tailwind classes globally */
.bg-blue-600,
.bg-blue-700,
.bg-primary,
.bg-primary-600,
.bg-primary-700 {
    background-color: var(--button-color, var(--primary-color)) !important;
    color: var(--button-text-color, white) !important;
}

.bg-blue-600:hover,
.bg-blue-700:hover,
.bg-primary:hover,
.bg-primary-600:hover,
.bg-primary-700:hover,
.hover\:bg-blue-700:hover,
.hover\:bg-primary-700:hover {
    filter: brightness(0.9);
}

.text-blue-600,
.text-blue-700,
.text-blue-800 {
    color: var(--link-color, var(--primary-color)) !important;
}

.text-blue-600:hover,
.text-blue-700:hover,
.hover\:text-blue-700:hover,
.hover\:text-blue-800:hover {
    color: var(--link-hover-color, var(--primary-color)) !important;
}

/* Form focus states - use brand colors */
.focus\:border-blue-500:focus,
.focus\:ring-blue-500:focus {
    border-color: var(--primary-color) !important;
}

.focus\:ring-blue-500:focus {
    --tw-ring-color: var(--primary-color) !important;
}

/* Pagination active state */
.border-blue-500 {
    border-color: var(--primary-color) !important;
}

.bg-blue-50 {
    background-color: color-mix(in srgb, var(--primary-color) 10%, white) !important;
}

/* File input styling */
.file\:bg-blue-50::file-selector-button {
    background-color: color-mix(in srgb, var(--primary-color) 10%, white) !important;
}

.file\:text-blue-700::file-selector-button {
    color: var(--primary-color) !important;
}

.hover\:file\:bg-blue-100:hover::file-selector-button {
    background-color: color-mix(in srgb, var(--primary-color) 20%, white) !important;
}

/* Icon colors in document list */
.bg-blue-100 {
    background-color: color-mix(in srgb, var(--primary-color) 15%, white) !important;
}

/* Card hover effect */
.card-hover {
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.card-hover:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Document preview */
.document-preview {
    font-family: 'Times New Roman', Times, serif;
    line-height: 1.6;
}

.document-preview h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.document-preview h2 {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
}

.document-preview p {
    margin-bottom: 0.75rem;
    text-align: justify;
}

/* Template editor */
.template-editor {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.template-variable {
    background-color: #fef3c7;
    color: #92400e;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.template-condition {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* Status badges */
.status-draft {
    background-color: #f3f4f6;
    color: #374151;
}

.status-final {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-signed {
    background-color: #d1fae5;
    color: #065f46;
}

.status-error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Priority badges */
.priority-urgent {
    background-color: #fee2e2;
    color: #991b1b;
}

.priority-high {
    background-color: #ffedd5;
    color: #9a3412;
}

.priority-normal {
    background-color: #dbeafe;
    color: #1e40af;
}

.priority-low {
    background-color: #f3f4f6;
    color: #374151;
}

/* Sidebar navigation */
.sidebar-nav-item {
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.sidebar-nav-item:hover {
    background-color: #f3f4f6;
}

.sidebar-nav-item.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

/* Dropdown animation */
.dropdown-enter {
    opacity: 0;
    transform: scale(0.95);
}

.dropdown-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.1s ease-out, transform 0.1s ease-out;
}

.dropdown-leave {
    opacity: 1;
    transform: scale(1);
}

.dropdown-leave-active {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.075s ease-in, transform 0.075s ease-in;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 50;
    animation: slide-in 0.3s ease-out;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Dark mode styles */
.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

.dark .sidebar-nav-item:hover {
    background-color: #374151;
}

.dark .sidebar-nav-item.active {
    background-color: #1f2937;
}

/* Dark mode page headers and common text elements */
/* Comprehensive dark mode text color fixes for dashboard content */

/* Page titles - h1, h2, h3 with gray-900 */
.dark .dashboard-content h1,
.dark .dashboard-content h2,
.dark .dashboard-content h3,
.dark .dashboard-content h4 {
    color: #f9fafb;
}

/* Preserve specific colored text */
.dark .dashboard-content h1.text-white,
.dark .dashboard-content h2.text-white,
.dark .dashboard-content h3.text-white {
    color: white !important;
}

/* Page descriptions and secondary text */
.dark .dashboard-content p.text-gray-500,
.dark .dashboard-content p.text-gray-600,
.dark .dashboard-content span.text-gray-500,
.dark .dashboard-content span.text-gray-600,
.dark .dashboard-content div.text-gray-500,
.dark .dashboard-content div.text-gray-600 {
    color: #9ca3af !important;
}

/* Labels and form text */
.dark .dashboard-content label.text-gray-700,
.dark .dashboard-content label {
    color: #d1d5db;
}

/* Table headers */
.dark .dashboard-content th {
    color: #9ca3af;
}

/* Table cell text */
.dark .dashboard-content td .text-gray-900,
.dark .dashboard-content .text-sm.font-medium.text-gray-900,
.dark .dashboard-content .text-sm.text-gray-900 {
    color: #f3f4f6 !important;
}

.dark .dashboard-content td .text-gray-500,
.dark .dashboard-content td .text-xs.text-gray-500 {
    color: #9ca3af !important;
}

/* Card section headers */
.dark .dashboard-content .border-b h3,
.dark .dashboard-content .px-6.py-5 h3 {
    color: #f3f4f6;
}

/* Info text in cards */
.dark .dashboard-content .text-xs.text-gray-500,
.dark .dashboard-content .mt-1.text-sm.text-gray-500 {
    color: #9ca3af !important;
}

/* Table backgrounds for dark mode */
.dark .dashboard-content .bg-gray-50 {
    background-color: #374151 !important;
}

.dark .dashboard-content .bg-white {
    background-color: #1f2937 !important;
}

.dark .dashboard-content .hover\:bg-gray-50:hover {
    background-color: #374151 !important;
}

/* Borders for dark mode */
.dark .dashboard-content .border-gray-200,
.dark .dashboard-content .divide-gray-200 > * {
    border-color: #374151 !important;
}

.dark .dashboard-content .border-gray-300 {
    border-color: #4b5563 !important;
}

/* Shadow adjustments for dark mode */
.dark .dashboard-content .shadow {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
}

/* Button/link text that should stay readable */
.dark .dashboard-content .text-gray-700 {
    color: #d1d5db !important;
}

/* Empty state text */
.dark .dashboard-content .text-center .text-gray-900,
.dark .dashboard-content .text-center .text-sm.font-medium.text-gray-900 {
    color: #f3f4f6 !important;
}

.dark .dashboard-content .text-center .text-gray-500 {
    color: #9ca3af !important;
}

/* Pagination text */
.dark .dashboard-content nav .text-gray-700 {
    color: #d1d5db !important;
}

/* Stat card numbers - important for dashboard, reports, inbox */
.dark .dashboard-content dd.text-lg,
.dark .dashboard-content dd.text-2xl,
.dark .dashboard-content .text-lg.font-semibold.text-gray-900,
.dark .dashboard-content .text-2xl.font-bold.text-gray-900,
.dark .dashboard-content dl dd {
    color: #f9fafb !important;
}

/* Stat card labels */
.dark .dashboard-content dt.text-sm,
.dark .dashboard-content dl dt {
    color: #9ca3af !important;
}

/* Signature detail page and similar detail pages */
.dark .dashboard-content .text-gray-800,
.dark .dashboard-content p.font-medium.text-gray-800,
.dark .dashboard-content h1.text-gray-800,
.dark .dashboard-content h2.text-gray-800,
.dark .dashboard-content .text-lg.font-semibold.text-gray-800 {
    color: #f3f4f6 !important;
}

/* Detail page secondary text */
.dark .dashboard-content .text-sm.text-gray-500,
.dark .dashboard-content p.text-gray-500 {
    color: #9ca3af !important;
}

/* Address and other text blocks */
.dark .dashboard-content address.text-sm.text-gray-900,
.dark .dashboard-content .text-sm.text-gray-900 {
    color: #f3f4f6 !important;
}

/* Breadcrumb navigation */
.dark .dashboard-content nav.text-sm.text-gray-500 {
    color: #9ca3af !important;
}

.dark .dashboard-content nav.text-sm .text-gray-700 {
    color: #d1d5db !important;
}

/* Links in dark mode */
.dark .dashboard-content a.text-blue-600,
.dark .dashboard-content a.text-blue-800 {
    color: #60a5fa !important;
}

.dark .dashboard-content a.text-blue-600:hover,
.dark .dashboard-content a.text-blue-800:hover {
    color: #93c5fd !important;
}

.dark .template-variable {
    background-color: #78350f;
    color: #fef3c7;
}

.dark .template-condition {
    background-color: #1e3a8a;
    color: #dbeafe;
}

.dark .status-draft {
    background-color: #374151;
    color: #d1d5db;
}

.dark .status-final {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.dark .status-pending {
    background-color: #78350f;
    color: #fde68a;
}

.dark .status-signed {
    background-color: #064e3b;
    color: #6ee7b7;
}

.dark .status-error {
    background-color: #7f1d1d;
    color: #fca5a5;
}

.dark .priority-urgent {
    background-color: #7f1d1d;
    color: #fca5a5;
}

.dark .priority-high {
    background-color: #7c2d12;
    color: #fdba74;
}

.dark .priority-normal {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.dark .priority-low {
    background-color: #374151;
    color: #d1d5db;
}

.dark .spinner {
    border-color: #374151;
    border-top-color: var(--primary-color);
}

/* Dark mode form styles - only apply within authenticated dashboard areas */
.dark .dashboard-content input[type="text"],
.dark .dashboard-content input[type="email"],
.dark .dashboard-content input[type="password"],
.dark .dashboard-content input[type="number"],
.dark .dashboard-content input[type="date"],
.dark .dashboard-content input[type="datetime-local"],
.dark .dashboard-content input[type="tel"],
.dark .dashboard-content input[type="url"],
.dark .dashboard-content select,
.dark .dashboard-content textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.dark .dashboard-content input[type="text"]::placeholder,
.dark .dashboard-content input[type="email"]::placeholder,
.dark .dashboard-content input[type="password"]::placeholder,
.dark .dashboard-content textarea::placeholder {
    color: #9ca3af;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
    }

    .document-preview {
        padding: 0;
        margin: 0;
    }
}

/* Responsive table */
@media (max-width: 640px) {
    .responsive-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* HTMX loading indicator */
.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
}

/* Prose styles for document content */
.prose {
    max-width: 65ch;
}

.prose p {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
}

.prose h1 {
    font-size: 2.25em;
    margin-top: 0;
    margin-bottom: 0.8888889em;
    line-height: 1.1111111;
}

.prose h2 {
    font-size: 1.5em;
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.3333333;
}

.prose h3 {
    font-size: 1.25em;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    line-height: 1.6;
}

.prose ul {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-left: 1.625em;
    list-style-type: disc;
}

.prose ol {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-left: 1.625em;
    list-style-type: decimal;
}

.prose li {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}
