/* Regex Tester Tool Styles */

/* Container and Layout */
.regex-tester-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
}

/* Header Styling */
.header-section h1 {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Pattern Library */
.pattern-library-panel {
    border: 1px solid #e5e7eb;
}

.pattern-category h3 {
    color: #1f2937;
    font-weight: 600;
}

.pattern-btn {
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    cursor: pointer;
}

.pattern-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.pattern-btn:active {
    background: #dbeafe;
}

/* Panel Styling */
.input-panel,
.test-string-panel,
.results-panel {
    border: 1px solid #e5e7eb;
}

.panel-header h2 {
    color: #1f2937;
    font-weight: 600;
}

/* Action Buttons */
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.action-btn:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Regex Input Styling */
.regex-input-wrapper {
    position: relative;
}

.regex-input-wrapper input {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

#regexPattern {
    font-size: 16px;
    color: #1f2937;
}

#regexFlags {
    font-size: 16px;
    color: #6b7280;
    text-align: center;
}

/* Pattern Status */
.pattern-status {
    margin-top: 8px;
}

.pattern-status.valid {
    color: #059669;
}

.pattern-status.invalid {
    color: #dc2626;
}

.pattern-status.warning {
    color: #d97706;
}

/* Flags Info */
.flags-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.flag-item {
    margin-right: 12px;
    padding: 2px 6px;
    background: white;
    border-radius: 4px;
    font-size: 12px;
}

.flag-item code {
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

/* Operation Mode */
.operation-mode input[type="radio"] {
    accent-color: #3b82f6;
}

.operation-mode label {
    cursor: pointer;
}

/* Replacement Section */
.replacement-section {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 16px;
}

.replacement-section input {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

/* Action Buttons */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Test String Area */
.test-string-wrapper {
    position: relative;
}

#testString {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    background: white;
    z-index: 1;
    position: relative;
}

/* Syntax Highlighting Overlay */
.test-string-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
    background: transparent;
}

.highlighted-text {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    color: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
}

/* Match Highlighting */
.match-highlight {
    background-color: rgba(59, 130, 246, 0.3);
    border-radius: 3px;
    padding: 1px 2px;
    margin: 0 1px;
}

.match-highlight.active {
    background-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.8);
}

.group-highlight-1 {
    background-color: rgba(239, 68, 68, 0.3);
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.group-highlight-2 {
    background-color: rgba(16, 185, 129, 0.3);
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.group-highlight-3 {
    background-color: rgba(245, 158, 11, 0.3);
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.group-highlight-4 {
    background-color: rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.5);
}

/* String Info */
.string-info {
    font-size: 12px;
    color: #6b7280;
    padding: 8px 0;
    border-top: 1px solid #e5e7eb;
}

/* Results Panel */
.results-tabs {
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
    border: 1px solid #e2e8f0;
    border-bottom: none;
}

.tab-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
    position: relative;
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.tab-btn:hover:not(.active) {
    color: #1f2937;
}

.tab-content {
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    min-height: 300px;
    background: white;
}

.tab-panel {
    padding: 20px;
}

.tab-panel.hidden {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: #d1d5db;
}

.empty-state p {
    margin: 8px 0;
}

/* Match Results */
.match-result {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.match-result-header {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    display: flex;
    justify-content: between;
    align-items: center;
}

.match-index {
    background: #3b82f6;
    color: white;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 12px;
    margin-right: 8px;
}

.match-text {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0;
    font-size: 14px;
    word-break: break-all;
}

.match-position {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* Capture Groups */
.capture-group {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 8px;
    margin: 8px 0;
}

.capture-group-header {
    font-weight: 600;
    color: #92400e;
    font-size: 13px;
    margin-bottom: 4px;
}

.capture-group-text {
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 14px;
    color: #1f2937;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Pattern Explanation */
.explanation-section {
    margin-bottom: 20px;
}

.explanation-section h4 {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    font-size: 14px;
}

.explanation-content {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    font-size: 14px;
}

.component-list {
    list-style: none;
    padding: 0;
}

.component-list li {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 4px 0;
    font-size: 13px;
}

.component-list li code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: "Courier New", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 4px 0;
    font-size: 13px;
    color: #92400e;
}

.tips-list li::before {
    content: "💡 ";
    margin-right: 4px;
}

/* Performance Indicator */
.performance-indicator {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
}

.performance-bar {
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
    overflow: hidden;
}

.performance-bar.excellent {
    background: linear-gradient(90deg, #10b981, #059669);
}

.performance-bar.good {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.performance-bar.average {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.performance-bar.slow {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.performance-bar.very-slow {
    background: linear-gradient(90deg, #7f1d1d, #991b1b);
}

/* Loading Spinner */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Loading Overlay */
.loading-overlay.show {
    display: flex !important;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.toast {
    background: white;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    min-width: 300px;
    position: relative;
    overflow: hidden;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast.info {
    border-left-color: #3b82f6;
}

.toast-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.toast-icon.success {
    color: #10b981;
}

.toast-icon.error {
    color: #ef4444;
}

.toast-icon.warning {
    color: #f59e0b;
}

.toast-icon.info {
    color: #3b82f6;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 14px;
    color: #6b7280;
}

.toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
}

.toast-close:hover {
    color: #6b7280;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: currentColor;
    opacity: 0.3;
    animation: toastProgress 3s linear forwards;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Error States */
.error-message {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 12px;
    color: #dc2626;
    font-size: 14px;
    margin: 8px 0;
}

.error-message .error-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.error-suggestions {
    margin-top: 8px;
    font-size: 13px;
}

.error-suggestions ul {
    list-style-type: disc;
    padding-left: 20px;
    margin: 4px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .regex-tester-container {
        padding: 16px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .pattern-library-panel .grid {
        grid-template-columns: 1fr;
    }

    .flags-info {
        font-size: 12px;
    }

    .flag-item {
        display: block;
        margin: 4px 0;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin-bottom: 8px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .toast-container {
        left: 16px;
        right: 16px;
        top: 16px;
    }

    .toast {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .header-section h1 {
        font-size: 28px;
    }

    .header-section p {
        font-size: 16px;
    }

    .pattern-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    #testString {
        height: 120px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .performance-indicator {
        padding: 12px;
    }
}
