/* Synpulse Brand Colors */
:root {
    --synpulse-blue: #003366;
    --synpulse-orange: #FF6B35;
    --synpulse-dark-orange: #E85A28;
    --synpulse-light-gray: #F5F5F5;
    --synpulse-dark-gray: #2C2C2C;
}

/* Gradient Background */
.synpulse-gradient {
    background: linear-gradient(135deg, #f8f9fa 0%, #e3f2fd 25%, #ffe8e0 50%, #fff3f0 75%, #f5f5f5 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Custom Tailwind Configuration */
@layer utilities {
    .bg-synpulse-blue {
        background-color: var(--synpulse-blue);
    }
    
    .bg-synpulse-orange {
        background-color: var(--synpulse-orange);
    }
    
    .text-synpulse-blue {
        color: var(--synpulse-blue);
    }
    
    .text-synpulse-orange {
        color: var(--synpulse-orange);
    }
    
    .border-synpulse-blue {
        border-color: var(--synpulse-blue);
    }
    
    .border-synpulse-orange {
        border-color: var(--synpulse-orange);
    }
    
    .ring-synpulse-blue {
        --tw-ring-color: var(--synpulse-blue);
    }
    
    .ring-synpulse-orange {
        --tw-ring-color: var(--synpulse-orange);
    }
    
    .hover\:bg-synpulse-orange:hover {
        background-color: var(--synpulse-dark-orange);
    }
}

/* Tree Visualization Styles */
.tree-container {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: auto;
    padding: 1rem 0;
    gap: 1.5rem;
    min-height: 70vh;
    max-height: 85vh;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.tree-container.cursor-grabbing {
    cursor: grabbing !important;
}

.tree-container.cursor-grabbing * {
    cursor: grabbing !important;
    pointer-events: none; /* Prevent interactions while dragging */
}

.tree-container:not(.cursor-grabbing) button,
.tree-container:not(.cursor-grabbing) details,
.tree-container:not(.cursor-grabbing) summary {
    cursor: pointer;
    pointer-events: auto;
}

.tree-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tree-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

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

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

.tree-container::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

.tree-stage {
    min-width: 250px;
    max-width: 280px;
    flex-shrink: 0;
}

.tree-stage-header {
    cursor: pointer;
    padding: 1rem;
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    border-top: 4px solid var(--synpulse-orange);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tree-stage-header:hover {
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.15);
}

.tree-stage-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tree-rule {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.tree-rule:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rule-expand-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rule-expand-btn:hover svg {
    color: #003366;
}

.rule-expand-btn svg {
    transition: transform 0.3s ease;
}

.tree-rule.regulatory {
    border-left: 4px solid #FF6B35;
}

.tree-rule.guideline {
    border-left: 4px solid #003366;
}

.tree-rule.best-practice {
    border-left: 4px solid #6bcf7f;
}

.tree-rule-children {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    padding-left: 0.75rem;
    border-top: 2px dashed #adb5bd;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.rule-type-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.rule-type-badge.regulatory {
    background-color: #FFE8E0;
    color: #E85A28;
}

.rule-type-badge.guideline {
    background-color: #E6F0FF;
    color: #003366;
}

.rule-type-badge.best-practice {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* Heatmap Styles */
.heatmap-cell {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    z-index: 10;
    position: relative;
}

.heatmap-cell.gap-high {
    background-color: #ff6b6b;
    color: white;
}

.heatmap-cell.gap-medium {
    background-color: #ffd93d;
    color: #333;
}

.heatmap-cell.gap-low {
    background-color: #6bcf7f;
    color: white;
}

.heatmap-cell.no-gap {
    background-color: #95e1d3;
    color: white;
}

/* Collapsible Icon */
.collapse-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    margin-right: 0.5rem;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

/* Inline Editing */
.editable {
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.editable:hover {
    background-color: #f8f9fa;
}

.editable.editing {
    background-color: #fff;
    border: 2px solid var(--synpulse-blue);
    outline: none;
}

/* Button Contrast Improvements */
button.bg-gray-200,
button.bg-gray-100,
button.bg-gray-50 {
    background-color: #cbd5e1 !important;
    color: #0f172a !important;
    font-weight: 700;
    border: 2px solid #94a3b8;
}

button.bg-blue-100 {
    color: #0b1f33 !important;
    font-weight: 600;
}

button.bg-white.text-synpulse-blue {
    font-weight: 700;
}

button.bg-synpulse-orange,
button.bg-synpulse-orange:hover {
    color: white !important;
    font-weight: 600;
}

/* Ensure Add Rule button is always visible with maximum contrast */
#addRuleBtnNav,
#gapAnalysisBtn {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10;
    background-color: #FF6B35 !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    border: 2px solid #E85A28 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

#addRuleBtnNav:hover,
#gapAnalysisBtn:hover {
    background-color: #E85A28 !important;
    border-color: #CC4A1F !important;
}

#logoutBtn {
    background-color: #1F2937 !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    border: 2px solid #111827 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

#logoutBtn:hover {
    background-color: #111827 !important;
    border-color: #030712 !important;
}

/* View toggle buttons */
#viewBothBtn,
#viewTreeBtn,
#viewLibraryBtn {
    color: #0f172a !important;
    font-weight: 700 !important;
}

/* Clear filters button */
#clearFilters {
    background-color: #9ca3af !important;
    color: #111827 !important;
    font-weight: 700 !important;
    border: 2px solid #6b7280 !important;
}

/* Smooth Transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Logic formatting */
.logic-formatted {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
}

.logic-formatted ul {
    margin: 0;
    padding-left: 0;
}

.logic-formatted li {
    margin: 0.125rem 0;
}

details summary {
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details[open] summary {
    margin-bottom: 0.25rem;
}

/* Library table container */
#libraryTableContainer {
    max-height: 60vh;
    overflow: auto;
    position: relative;
}

#libraryPanel.library-only-view #libraryTableContainer {
    max-height: calc(100vh - 250px);
}

#rulesTable {
    table-layout: auto;
    width: 100%;
}

#rulesTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa;
}

#rulesTable thead th {
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.75rem 1rem;
}

#rulesTable tbody td {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Wider columns for specific fields */
#rulesTable tbody td:nth-child(2) {
    max-width: 250px;
}

#rulesTable tbody td:nth-child(4),
#rulesTable tbody td:nth-child(5) {
    max-width: 150px;
}

/* Modal gradient background */
.modal-gradient-bg {
    background: linear-gradient(135deg, #ffffff 0%, #fef8f5 20%, #fff5f0 40%, #fef8f5 60%, #ffffff 100%);
}

/* Modal Styling Enhancements */
#ruleModal input,
#ruleModal textarea,
#ruleModal select,
#gapAnalysisModal input,
#gapAnalysisModal textarea,
#gapAnalysisModal select {
    background-color: white !important;
    color: #1f2937 !important;
}

/* Description textarea specific styling */
#ruleDescription {
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#ruleModal input:focus,
#ruleModal textarea:focus,
#ruleModal select:focus,
#gapAnalysisModal input:focus,
#gapAnalysisModal textarea:focus,
#gapAnalysisModal select:focus {
    border-color: var(--synpulse-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
    background-color: white !important;
}

#ruleModal input::placeholder,
#ruleModal textarea::placeholder,
#gapAnalysisModal input::placeholder,
#gapAnalysisModal textarea::placeholder {
    color: #9ca3af !important;
    font-style: italic;
}

#ruleModal label,
#gapAnalysisModal label {
    letter-spacing: 0.025em;
    color: #374151 !important;
    font-weight: 600;
}

/* Modal header gradient animation */
#ruleModal .bg-gradient-to-r,
#gapAnalysisModal .bg-gradient-to-r {
    background-size: 200% 100%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Button contrast improvements */
#ruleModal button[type="submit"],
#gapAnalysisModal button {
    color: #1f2937 !important;
    font-weight: 600;
}

#ruleModal button[type="button"],
#gapAnalysisModal button[type="button"] {
    font-weight: 600;
}

/* Add Attribute button contrast */
#addAttributeBtn {
    background-color: #4b5563 !important;
    color: white !important;
    border-color: #374151 !important;
}

#addAttributeBtn:hover {
    background-color: #374151 !important;
    border-color: #1f2937 !important;
}

/* Cancel button contrast */
#cancelModal {
    background-color: white !important;
    color: #1f2937 !important;
    border-color: #9ca3af !important;
}

#cancelModal:hover {
    background-color: #f9fafb !important;
    border-color: #6b7280 !important;
}

/* Select dropdown styling */
#ruleModal select option,
#gapAnalysisModal select option {
    background-color: white;
    color: #1f2937;
    padding: 8px;
}

/* Close button hover effect */
#closeModal:hover,
#closeGapModal:hover {
    transform: scale(1.1);
}

/* Text shadow for modal titles */
.drop-shadow-md {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Required asterisk styling */
.text-synpulse-orange {
    color: var(--synpulse-orange) !important;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

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

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

/* Markdown styling for AI Assistant chat messages */
#chatMessages .prose {
    color: #1f2937;
    line-height: 1.6;
}

#chatMessages .prose h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    color: #111827;
    border-bottom: 2px solid var(--synpulse-orange);
    padding-bottom: 0.5rem;
}

#chatMessages .prose h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

#chatMessages .prose h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

#chatMessages .prose h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    color: #4b5563;
}

#chatMessages .prose p {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#chatMessages .prose ul,
#chatMessages .prose ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

#chatMessages .prose ul {
    list-style-type: disc;
}

#chatMessages .prose ol {
    list-style-type: decimal;
}

#chatMessages .prose li {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

#chatMessages .prose li > p {
    margin-top: 0;
    margin-bottom: 0;
}

#chatMessages .prose strong {
    font-weight: 600;
    color: #111827;
}

#chatMessages .prose em {
    font-style: italic;
}

#chatMessages .prose code {
    background-color: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-family: 'Courier New', monospace;
    color: #dc2626;
}

#chatMessages .prose pre {
    background-color: #f3f4f6;
    padding: 0.75rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#chatMessages .prose pre code {
    background-color: transparent;
    padding: 0;
    color: #1f2937;
}

#chatMessages .prose blockquote {
    border-left: 4px solid var(--synpulse-orange);
    padding-left: 1rem;
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    color: #4b5563;
    font-style: italic;
}

#chatMessages .prose a {
    color: var(--synpulse-orange);
    text-decoration: underline;
}

#chatMessages .prose a:hover {
    color: var(--synpulse-dark-orange);
}

#chatMessages .prose hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#chatMessages .prose table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#chatMessages .prose th,
#chatMessages .prose td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: left;
}

#chatMessages .prose th {
    background-color: #f9fafb;
    font-weight: 600;
}

