/* TripleTen Brand Colors */
:root {
    --triplet-primary: #f89e93;
    --triplet-secondary: #ff976a;
    --triplet-success: #10b981;
    --triplet-warning: #f59e0b;
    --triplet-danger: #ef4444;
    --triplet-info: #3b82f6;
    --triplet-light: #f8fafc;
    --triplet-dark: #1e293b;
    
    /* Highlight colors from brand assets */
    --highlight-red: #fecaca;
    --highlight-orange: #fed7aa;
    --highlight-yellow: #fef3c7;
    --highlight-green: #bbf7d0;
    --highlight-blue: #bfdbfe;
    --highlight-purple: #ddd6fe;
    
    /* Text colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Background colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: transparent;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* Iframe width limitation and rounded corners */
.container-fluid {
    max-width: min(1230px, calc(100% - 30px)); /* Use the smaller of 1230px or viewport minus margins */
    margin: 15px auto !important; /* Center when at 1230px limit */
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--bg-primary);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Header Styles */
.triplet-header {
    background: linear-gradient(135deg, var(--triplet-primary) 0%, var(--triplet-secondary) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.triplet-header h1 {
    font-weight: 600;
    color: white;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* Toolbar Styles */
.toolbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.btn-outline-primary {
    border-color: var(--triplet-primary);
    color: var(--triplet-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary {
    background-color: var(--triplet-primary);
    border-color: var(--triplet-primary);
    color: white;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--triplet-secondary);
    border-color: var(--triplet-secondary);
}

/* Input Section */
.input-section {
    height: 550px;
}

.input-panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    flex-shrink: 0;
}

.textarea-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.diff-textarea {
    flex: 1;
    border: none;
    border-radius: 0;
    resize: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 16px;
    background-color: var(--bg-primary);
    overflow: auto;
    white-space: nowrap;
    word-wrap: normal;
    overflow-wrap: normal;
}

.diff-textarea:focus {
    box-shadow: none;
    border: none;
    outline: 2px solid var(--triplet-primary);
    outline-offset: -2px;
}

/* Drag and Drop Styles */
.drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.1);
    border: 2px dashed var(--triplet-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--triplet-primary);
    font-size: 18px;
    display: none;
    z-index: 10;
}

.drop-zone.active {
    display: flex;
    background: rgba(99, 102, 241, 0.2);
}

.drop-zone i {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    border-top: 2px solid var(--bg-tertiary);
    min-height: 200px;
    /* Remove max-height to allow content expansion */
}

.stats-bar {
    flex-shrink: 0;
    background-color: var(--bg-secondary);
}

.stat-item {
    font-size: 14px;
    font-weight: 500;
}

.diff-container {
    flex: 1;
    overflow: auto;
    background-color: var(--bg-primary);
    /* Allow dynamic height expansion */
    min-height: 400px;
    max-height: 800px;
}

/* Diff Display Styles */
.diff-view {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.diff-side-by-side {
    display: flex;
    height: 100%;
}

.diff-side {
    flex: 1;
    overflow: auto;
    border-right: 1px solid var(--bg-tertiary);
    min-height: 400px;
    max-height: 800px;
}

.diff-side:last-child {
    border-right: none;
}

.diff-line {
    display: flex;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-line-number {
    width: 60px;
    flex-shrink: 0;
    padding: 4px 8px;
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    text-align: right;
    font-size: 12px;
    border-right: 1px solid var(--bg-tertiary);
    user-select: none;
}

.diff-line-content {
    flex: 1;
    padding: 4px 8px;
    background-color: var(--bg-primary);
}

/* Diff Line Types */
.diff-line.added {
    background-color: rgba(16, 185, 129, 0.1);
}

.diff-line.added .diff-line-number {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--triplet-success);
}

.diff-line.removed {
    background-color: rgba(239, 68, 68, 0.1);
}

.diff-line.removed .diff-line-number {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--triplet-danger);
}

.diff-line.modified {
    background-color: rgba(245, 158, 11, 0.1);
}

.diff-line.modified .diff-line-number {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--triplet-warning);
}

.diff-line.context {
    background-color: var(--bg-primary);
}

/* Inline Diff View */
.diff-inline {
    width: 100%;
}

.diff-inline .diff-line {
    width: 100%;
}

.diff-inline .diff-line-number {
    width: 80px;
}

/* Character-level diff highlighting */
.char-added {
    background-color: rgba(16, 185, 129, 0.3);
    font-weight: 600;
}

.char-removed {
    background-color: rgba(239, 68, 68, 0.3);
    font-weight: 600;
    text-decoration: line-through;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: var(--triplet-primary);
}

/* Search Highlighting */
.search-highlight {
    background-color: var(--highlight-yellow);
    padding: 2px 4px;
    border-radius: 2px;
}

.search-highlight.current {
    background-color: var(--triplet-warning);
    color: white;
}

/* Syntax Highlighting Base Styles */
.highlight {
    background-color: transparent;
}

.highlight .k { color: #0000ff; } /* Keyword */
.highlight .s { color: #008000; } /* String */
.highlight .c { color: #808080; font-style: italic; } /* Comment */
.highlight .n { color: #000000; } /* Name */
.highlight .o { color: #666666; } /* Operator */
.highlight .p { color: #666666; } /* Punctuation */
.highlight .nb { color: #0000ff; } /* Name.Builtin */
.highlight .nf { color: #800080; } /* Name.Function */
.highlight .nc { color: #0000ff; } /* Name.Class */
.highlight .nn { color: #0000ff; } /* Name.Namespace */

@media (max-width: 768px) {
    /* Allow dynamic height expansion */
    .main-content {
        min-height: 600px; /* Minimum height for mobile */
        height: auto; /* Allow content to expand */
        overflow-y: visible;
        display: flex;
        flex-direction: column;
    }
    /* Larger when results shown - allow dynamic height */
    .main-content.has-results {
        min-height: 800px; /* Minimum height when results shown */
        height: auto; /* Allow content to expand */
    }
    /* Input section always 620px */
    .input-section {
        height: 620px;
        flex-shrink: 0;
    }
    /* Results section dynamic height - expands with content */
    .results-section {
        min-height: 200px;
        /* Remove fixed height to allow content expansion */
        overflow: visible; /* No scroll bar inside results */
    }
    /* Keep all other mobile adjustments */
    .triplet-header {
        padding: 0.5rem 1rem !important;
    }
    .triplet-header h1 {
        font-size: 1.1rem;
    }
    .toolbar {
        padding: 0.5rem 1rem !important;
    }
    .input-section .col-md-6 {
        border-bottom: 1px solid var(--bg-tertiary);
        border-right: none;
    }
    .diff-side-by-side {
        flex-direction: column;
    }
    .diff-side {
        border-right: none;
        border-bottom: 1px solid var(--bg-tertiary);
    }
    .diff-side:last-child {
        border-bottom: none;
    }

    /* Remove internal scroll from diff-container */
    .diff-container {
        overflow: visible; /* No internal scroll */
        max-height: none; /* Remove height limit */
        min-height: auto; /* Remove min-height */
        height: auto; /* Natural height */
    }

    /* Also remove scroll from diff-side */
    .diff-side {
        overflow: visible; /* No internal scroll */
        max-height: none; /* Remove height limit */
        min-height: auto; /* Remove min-height */
    }
    
}
    /* Mobile stats bar optimizations */
    .stats-bar {
        padding: 0.5rem 1rem !important; /* Reduce from p-3 */
    }
    
    .stats-bar .row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        margin: 0;
        gap: 0.5rem;
    }
    
    .stats-bar .col-md-8,
    .stats-bar .col-md-4 {
        flex: none;
        width: auto;
        padding: 0;
    }
    
    .stats-bar .d-flex {
        gap: 0.25rem !important; /* Even smaller gap */
        flex-wrap: wrap;
    }
    
    
    .stats-bar .col-md-4 {
        text-align: right;
    }
    
    #search-btn {
        padding: 0.25rem 0.5rem;
        font-size: 14px;
        min-width: 0;
        flex-shrink: 1;
    }
    
    /* Ensure no horizontal overflow */
    .stats-bar {
        overflow-x: hidden;
        width: 100%;
    }
}
/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    outline: 2px solid var(--triplet-primary);
    outline-offset: 2px;
}

/* Custom scrollbar */
.diff-container::-webkit-scrollbar,
.diff-side::-webkit-scrollbar,
.diff-textarea::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.diff-container::-webkit-scrollbar-track,
.diff-side::-webkit-scrollbar-track,
.diff-textarea::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.diff-container::-webkit-scrollbar-thumb,
.diff-side::-webkit-scrollbar-thumb,
.diff-textarea::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.diff-container::-webkit-scrollbar-thumb:hover,
.diff-side::-webkit-scrollbar-thumb:hover,
.diff-textarea::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Validation Error Highlighting */
.validation-error-marker {
    animation: blink 1s infinite;
}

.validation-error-underline {
    animation: fadeIn 0.3s ease-in;
}

.validation-error-exclamation {
    animation: pulse 2s infinite;
    user-select: none;
    z-index: 2;
    position: absolute;
}

.validation-error-exclamation:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 0 3px rgba(239, 68, 68, 0.6));
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Ensure text areas have relative positioning for error markers */
.diff-input-group {
    position: relative;
}

/* Line Numbers */
.line-numbers {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 100%;
    max-height: 100%;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 16px 8px 16px 8px;
    text-align: right;
    white-space: pre;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1;
    user-select: none;
    pointer-events: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    box-sizing: border-box;
}

/* Hide scrollbars in line numbers for webkit browsers */
.line-numbers::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

/* Make room for line numbers and exclamation marks */
.diff-textarea {
    padding: 16px 16px 16px 74px; /* Match line numbers padding exactly */
    white-space: nowrap;
    word-wrap: normal;
    overflow-wrap: normal;
}

/* Adjust exclamation mark position to account for line numbers */
.validation-error-exclamation {
    left: 52px !important; /* Position after line numbers */
}

/* Character-level diff highlighting */
.char-removed {
    background-color: rgba(239, 68, 68, 0.3);
    color: #991b1b;
    text-decoration: line-through;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 500;
}

.char-added {
    background-color: rgba(34, 197, 94, 0.3);
    color: #166534;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 500;
}

/* Enhanced diff line styling for character diffs */
.diff-line.added .char-added {
    background-color: rgba(34, 197, 94, 0.5);
}

.diff-line.removed .char-removed {
    background-color: rgba(239, 68, 68, 0.5);
}

/* Print styles */
@media print {
    .triplet-header,
    .toolbar,
    .stats-bar {
        display: none;
    }
    
    .main-content {
        height: auto;
    }
    
    .diff-container {
        overflow: visible;
        height: auto;
    }
}
