/* Regex Tester Styles */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --background: #ffffff;
    --surface: #f8f9fa;
    --text: #2c3e50;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --match-highlight: #ffeb3b;
    --match-highlight-bg: rgba(255, 235, 59, 0.3);
}

[data-theme="dark"] {
    --background: #1a1a1a;
    --surface: #2d2d2d;
    --text: #ffffff;
    --text-secondary: #b0b0b0;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --match-highlight: #ffc107;
    --match-highlight-bg: rgba(255, 193, 7, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    transition: var(--transition);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    color: var(--text);
    margin-bottom: 30px;
    font-size: 2.5em;
}

h2 {
    color: var(--text);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

/* Regex Input Section */
.regex-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.regex-flags {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.flag-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.flag-label input[type="checkbox"] {
    display: none;
}

.flag-label > span:first-of-type {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    text-align: center;
    line-height: 20px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--text-secondary);
    transition: var(--transition);
}

.flag-label input[type="checkbox"]:checked + span {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.flag-tooltip {
    font-size: 12px;
    color: var(--text-secondary);
}

.regex-input-container {
    display: flex;
    align-items: stretch;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.regex-input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.regex-delimiter {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 15px 10px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border);
}

.regex-delimiter:last-child {
    border-right: none;
    border-left: 1px solid var(--border);
}

.regex-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 15px;
    resize: vertical;
    min-height: 60px;
    outline: none;
}

.regex-flags-display {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 15px 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.regex-info {
    display: flex;
    gap: 30px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status {
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
}

.status.valid {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status.invalid {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Test String Section */
.test-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.test-input-container {
    position: relative;
}

.test-input {
    width: 100%;
    min-height: 150px;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--background);
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 15px;
    resize: vertical;
    transition: var(--transition);
}

.test-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.test-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-end;
}

.test-actions button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.test-actions button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Results Section */
.results-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.highlighted-text {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 20px;
    min-height: 100px;
    white-space: pre-wrap;
    word-break: break-word;
}

.match-highlight {
    background: var(--match-highlight-bg);
    color: var(--text);
    font-weight: bold;
    border-radius: 3px;
    padding: 2px 4px;
    position: relative;
}

.match-highlight:hover::after {
    content: attr(data-match-info);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--background);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
}

.matches-list {
    max-height: 300px;
    overflow-y: auto;
}

.match-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.match-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px var(--shadow);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--primary-color);
}

.match-text {
    font-family: 'Courier New', monospace;
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
    word-break: break-all;
}

.match-groups {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Patterns Section */
.patterns-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.pattern-card {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.pattern-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-2px);
}

.pattern-card:active {
    transform: translateY(0);
}

.pattern-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.pattern-regex {
    font-family: 'Courier New', monospace;
    background: var(--surface);
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
    word-break: break-all;
    border-left: 4px solid var(--primary-color);
}

.pattern-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

/* Reference Section */
.reference-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.reference-category h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 18px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.reference-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reference-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 12px;
    background: var(--background);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.reference-item code {
    font-family: 'Courier New', monospace;
    background: var(--surface);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 60px;
    text-align: center;
}

.reference-item span {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Instructions */
.instructions {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 6px var(--shadow);
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 10px;
    line-height: 1.6;
    color: var(--text);
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: var(--transition);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--shadow);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 2em;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .regex-flags {
        justify-content: center;
        width: 100%;
    }

    .regex-input-container {
        flex-direction: column;
    }

    .regex-delimiter {
        border-right: none;
        border-bottom: 1px solid var(--border);
        justify-content: center;
    }

    .regex-delimiter:last-child {
        border-left: none;
        border-top: 1px solid var(--border);
        border-bottom: none;
    }

    .regex-input {
        min-height: 80px;
    }

    .regex-info {
        justify-content: center;
        gap: 20px;
    }

    .test-actions {
        justify-content: center;
    }

    .patterns-grid {
        grid-template-columns: 1fr;
    }

    .reference-grid {
        grid-template-columns: 1fr;
    }

    .match-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Loading state */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px 20px;
}

/* Success message */
.success-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}