/* Override global styles */
.container {
    max-width: 1400px !important;
    margin: 0 auto;
    padding: 2rem;
    text-align: left !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    text-align: left;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--link-color);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.8;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    padding: 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: fit-content;
}

.mode-tab {
    padding: 0.7rem 1.4rem;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-tab:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.04);
}

.mode-tab.active {
    background: rgba(77, 171, 247, 0.15);
    color: var(--link-color);
    font-weight: 600;
}

.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

/* Regex Input Bar */
.regex-input-bar {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.5rem 1rem;
}

.regex-delimiter {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 1.2rem;
    color: var(--link-color);
    font-weight: 700;
    padding: 0 0.25rem;
}

.regex-input-bar input#regexInput {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    color: #f39c12;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 1rem;
    outline: none;
}

.regex-input-bar input#regexInput::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.flags-input {
    width: 50px;
    padding: 0.6rem 0.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    color: #2ecc71;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9rem;
    text-align: center;
    outline: none;
    margin-left: 0.5rem;
}

.flags-input:focus {
    background: rgba(255, 255, 255, 0.08);
}

/* Status Bar */
.status-bar {
    display: flex;
    gap: 2rem;
    align-items: center;
    padding: 0.75rem 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--nav-submenu-bg);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-valid { color: #2ecc71; }
.status-invalid { color: #e74c3c; }
.status-empty { color: rgba(255, 255, 255, 0.3); }

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background: rgba(77, 171, 247, 0.1);
    border-color: rgba(77, 171, 247, 0.3);
    color: var(--link-color);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--link-color) 0%, #339af0 100%);
    color: #121212;
    border: none;
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #339af0 0%, #228be6 100%);
    color: #121212;
    box-shadow: 0 4px 15px rgba(77, 171, 247, 0.4);
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin-bottom: 1.5rem;
    position: relative;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
}

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

.panel-btn {
    padding: 0.35rem 0.7rem;
    border-radius: 5px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-btn:hover {
    background: rgba(77, 171, 247, 0.15);
    color: var(--link-color);
}

.btn-danger-sm:hover {
    background: rgba(231, 76, 60, 0.1) !important;
    color: #e74c3c !important;
}

/* Highlight area + textarea overlay */
.editor-panel .highlight-area {
    position: absolute;
    top: 49px; /* below panel-header */
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.25rem;
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    pointer-events: none;
    overflow: auto;
}

.editor-panel .editor-textarea {
    position: relative;
    z-index: 1;
    background: transparent;
    color: var(--text-color);
    caret-color: var(--text-color);
}

.editor-textarea {
    flex: 1;
    width: 100%;
    min-height: 200px;
    padding: 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 2;
    text-align: left;
}

.editor-textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

/* Match highlighting */
.match-highlight {
    background: rgba(243, 156, 18, 0.3);
    border-radius: 2px;
    border-bottom: 2px solid #f39c12;
}

.match-highlight-alt {
    background: rgba(46, 204, 113, 0.3);
    border-radius: 2px;
    border-bottom: 2px solid #2ecc71;
}

/* Match Details */
.match-details {
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.match-list {
    padding: 1.25rem;
    max-height: 250px;
    overflow-y: auto;
}

.match-item {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid #f39c12;
}

.match-item:nth-child(even) {
    border-left-color: #2ecc71;
}

.match-index {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    min-width: 30px;
}

.match-value {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #f39c12;
    word-break: break-all;
}

.match-item:nth-child(even) .match-value {
    color: #2ecc71;
}

.match-position {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-left: auto;
    white-space: nowrap;
}

.match-groups {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 2rem;
    padding: 0.25rem 0;
}

.match-groups span {
    color: var(--link-color);
    margin-right: 0.75rem;
}

.placeholder-text {
    color: rgba(255, 255, 255, 0.25);
}

/* Optimiser */
.optimiser-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.optimiser-actions {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0;
}

.optimiser-notes {
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem;
}

.opt-note {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.opt-note i {
    color: var(--link-color);
    margin-top: 0.15rem;
}

.opt-note.warning i {
    color: #f39c12;
}

.opt-note code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #f39c12;
}

/* Cheat Sheet */
.cheatsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.cheatsheet-section {
    background: var(--nav-submenu-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.cheatsheet-section h3 {
    padding: 1rem 1.25rem;
    margin: 0;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    color: var(--link-color);
}

.cheatsheet-table {
    width: 100%;
    border-collapse: collapse;
}

.cheatsheet-table td {
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
}

.cheatsheet-table tr:last-child td {
    border-bottom: none;
}

.cheatsheet-table td:first-child {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    color: #f39c12;
    white-space: nowrap;
    width: 100px;
}

.cheatsheet-table td:last-child {
    color: rgba(255, 255, 255, 0.6);
}

/* Examples section - full width, stacked layout */
.cheatsheet-examples {
    grid-column: 1 / -1;
    margin-top: 1.5rem;
}

.examples-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
    padding: 1.25rem;
}

.example-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
}

.example-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.4rem;
}

.example-pattern {
    display: block;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #f39c12;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    word-break: break-all;
    line-height: 1.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.85rem 1.5rem;
    background: var(--nav-submenu-bg);
    border: 1px solid rgba(77, 171, 247, 0.3);
    border-radius: 10px;
    color: var(--link-color);
    font-size: 0.9rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Mobile */
@media (max-width: 900px) {
    .container {
        padding: 1rem;
    }
    .mode-tabs {
        flex-wrap: wrap;
        width: 100%;
    }
    .regex-input-bar {
        flex-wrap: wrap;
    }
    .cheatsheet-grid {
        grid-template-columns: 1fr;
    }
}
