/* ================================
   Regex Tester & Visualizer Styling
================================ */

.tool-container {
    width: min(var(--max-width), calc(100% - 32px));
    margin: 40px auto 80px;
}

.back-link {
    display: inline-block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-light);
}

.tool-category-tag {
    color: var(--accent-light);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.tool-header h1 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 850;
    letter-spacing: -1px;
}

.tool-header p {
    color: var(--muted);
    font-size: 15px;
    margin-top: 6px;
    max-width: 680px;
}

/* Grid Layout */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    margin-top: 32px;
}

.main-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace-card, .sidebar-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--muted);
}

.preset-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    outline: none;
}

/* Regex Input Component */
.regex-input-box {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 14px;
    transition: border-color 0.2s;
}

.regex-input-box:focus-within {
    border-color: var(--accent);
}

.regex-slash {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 18px;
    color: var(--accent-light);
    font-weight: 700;
}

.regex-input-box input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 14px;
    padding: 12px 10px;
}

.flags-indicator {
    font-family: ui-monospace, SFMono-Regular, monospace;
    color: var(--accent-light);
    font-weight: 700;
    font-size: 14px;
}

/* Flags Controls */
.flags-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted);
}

.flags-label {
    font-weight: 700;
}

.flag-option {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.flag-option input {
    accent-color: var(--accent);
}

.regex-status {
    margin-top: 10px;
    font-size: 12px;
    min-height: 18px;
}

.regex-status.error {
    color: #ff6b6b;
}

/* Match Highlighter Area */
.editor-container {
    position: relative;
    width: 100%;
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.highlight-backdrop,
.editor-container textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 14px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-sizing: border-box;
    margin: 0;
    border: 0;
}

.highlight-backdrop {
    color: transparent;
    pointer-events: none;
    overflow-y: auto;
}

.editor-container textarea {
    background: transparent;
    color: var(--text);
    outline: none;
    resize: none;
    caret-color: var(--text);
}

/* Match Highlighting Mark Colors */
mark.highlight-match {
    background: rgba(57, 137, 255, 0.35);
    color: transparent;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(57, 137, 255, 0.6);
}

.match-count-badge {
    background: rgba(57, 137, 255, 0.15);
    color: var(--accent-light);
    border: 1px solid var(--border-hover);
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
}

/* Matches List */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.match-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
}

.match-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    color: var(--accent-light);
    margin-bottom: 6px;
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.empty-state {
    color: var(--muted);
    font-size: 13px;
}

/* Sidebar Cheat Sheet */
.sidebar-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
}

.cheat-group {
    margin-bottom: 18px;
}

.cheat-group h4 {
    font-size: 12px;
    color: var(--accent-light);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.cheat-group ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cheat-group li {
    font-size: 12px;
    color: var(--muted);
}

.cheat-group code {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 11px;
}

@media (max-width: 900px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}
