/* Regex Specific Styles */
.regex-container {
    max-width: 1400px;
    margin-bottom: 4rem;
}

.regex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tool-title {
    font-size: 2.25rem;
    color: var(--text-main);
    margin: 0;
}

.regex-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.regex-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .regex-layout {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-main);
}

/* Input Styles */
.regex-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.1rem;
}

.regex-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.regex-slash {
    color: var(--text-muted);
    font-weight: bold;
    padding: 0 0.5rem;
}

.regex-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    font-size: inherit;
    min-width: 0;
}

.regex-input.error {
    color: var(--danger);
}

.regex-flags-input {
    width: 60px;
    background: transparent;
    border: none;
    color: var(--primary);
    outline: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
}

/* Flags Toggle */
.flags-toggle {
    display: flex;
    gap: 0.25rem;
}

.flag-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-muted);
    cursor: pointer;
    font-family: monospace;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.flag-btn:hover {
    background: var(--bg-hover);
}

.flag-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Quick Examples */
.quick-example-btn {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.quick-example-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Editor with Highlights */
.editor-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-body);
    height: 400px;
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.05rem;
    line-height: 1.6;
}

.editor-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.highlights, .editor-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem;
    margin: 0;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    overflow-x: hidden;
}

.editor-textarea {
    background: transparent;
    color: var(--text-main);
    resize: none;
    outline: none;
    z-index: 2;
    -webkit-text-fill-color: transparent;
    caret-color: var(--text-main);
}

.highlights {
    z-index: 1;
    color: var(--text-main);
}

/* Highlighting styles */
mark.match-0 { background-color: rgba(59, 130, 246, 0.25); color: inherit; border-radius: 2px; }
mark.match-1 { background-color: rgba(16, 185, 129, 0.25); color: inherit; border-radius: 2px; }
mark.match-0, mark.match-1 { border-bottom: 1px solid transparent; }

/* Match Results */
.match-results-panel {
    height: 100%;
    max-height: 550px;
    display: flex;
    flex-direction: column;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.match-results-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.match-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
}

.match-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.match-value {
    font-family: monospace;
    background: var(--bg-surface);
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    word-break: break-all;
    font-size: 0.95rem;
}

.group-row {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

.group-num {
    color: var(--text-muted);
    width: 24px;
    font-weight: bold;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-surface);
    padding: 2.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-main);
}

.snippet-select {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}

.snippet-select:focus {
    border-color: var(--primary);
}

.snippet-code {
    background: var(--bg-body);
    padding: 1.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}
