* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 16px;
}

.btn-icon:hover {
    background: #e2e8f0;
    color: #fff;
}

.sidebar-section {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    overflow-y: auto;
}

.sidebar-section:first-of-type {
    flex: 1;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Preset List */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preset-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.preset-item:hover {
    background: #094771;
}

.preset-icon {
    font-size: 16px;
}

.preset-name {
    font-size: 13px;
}

/* Reference List */
.reference-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.reference-item {
    font-size: 12px;
    color: #a0a0a0;
    padding: 4px 0;
}

.reference-item code {
    background: #3c3c3c;
    padding: 2px 6px;
    border-radius: 3px;
    color: #4ec9b0;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Regex Section */
.regex-section {
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.regex-header {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.regex-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #3c3c3c;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0 10px;
    transition: border-color 0.2s;
}

.regex-input-wrapper:focus-within {
    border-color: #0f4ba5;
}

.regex-delimiter {
    color: #d4d4d4;
    font-size: 18px;
    font-weight: 300;
    user-select: none;
}

.regex-input {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    outline: none;
}

.flags-input {
    width: 60px;
    padding: 10px 0;
    background: transparent;
    border: none;
    color: #ce9178;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    outline: none;
    text-align: center;
}

.test-btn, .copy-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.test-btn {
    background: #0f4ba5;
    color: #fff;
}

.test-btn:hover {
    background: #005a9e;
}

.copy-btn {
    background: #3c3c3c;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.copy-btn:hover {
    background: #4c4c4c;
}

/* Flags Section */
.flags-section {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.flag-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.flag-checkbox input {
    display: none;
}

.flag-label {
    padding: 4px 12px;
    background: #3c3c3c;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    color: #64748b;
    transition: all 0.2s;
}

.flag-checkbox input:checked + .flag-label {
    background: #094771;
    border-color: #0f4ba5;
    color: #fff;
}

.flag-checkbox:hover .flag-label {
    border-color: #0f4ba5;
}

/* Regex Info */
.regex-info {
    display: flex;
    align-items: center;
    gap: 25px;
    font-size: 13px;
    color: #64748b;
}

.info-item strong {
    color: #fff;
    font-weight: 600;
}

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

.status-indicator.ready {
    background: #3c3c3c;
    color: #64748b;
}

.status-indicator.valid {
    background: #49cc9020;
    color: #49cc90;
    border: 1px solid #49cc90;
}

.status-indicator.invalid {
    background: #f93e3e20;
    color: #f93e3e;
    border: 1px solid #f93e3e;
}

/* Content Area */
.content-area {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    gap: 15px;
    padding: 15px;
    overflow: hidden;
}

.test-panel {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
}

.results-panel {
    grid-row: 1 / 3;
    grid-column: 2 / 3;
}

.replace-panel {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
}

.replace-result-panel {
    grid-row: 3 / 4;
    grid-column: 1 / 3;
}

/* Panels */
.panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 12px 15px;
    background: #edf5ff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: #e2e8f0;
    color: #fff;
}

.btn-text {
    background: transparent;
    border: none;
    color: #0f4ba5;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s;
}

.btn-text:hover {
    background: #094771;
    color: #fff;
}

.panel-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Test Textarea */
.test-textarea {
    width: 100%;
    height: 100%;
    padding: 15px;
    background: #ffffff;
    border: none;
    color: #d4d4d4;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.test-textarea::placeholder {
    color: #5a5a5a;
}

/* Highlight Overlay */
.highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 15px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    pointer-events: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    z-index: 1;
}

.highlight-match {
    background: rgba(206, 145, 120, 0.4);
    border-radius: 2px;
    padding: 1px 0;
}

.highlight-group-1 { background: rgba(78, 201, 176, 0.4); }
.highlight-group-2 { background: rgba(156, 220, 254, 0.4); }
.highlight-group-3 { background: rgba(220, 206, 120, 0.4); }
.highlight-group-4 { background: rgba(197, 134, 192, 0.4); }
.highlight-group-5 { background: rgba(181, 206, 168, 0.4); }

/* Replace Panel */
.replace-content {
    display: flex;
    gap: 10px;
    padding: 12px;
}

.replace-input {
    flex: 1;
    padding: 8px 12px;
    background: #3c3c3c;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    outline: none;
}

.replace-input:focus {
    border-color: #0f4ba5;
}

.replace-btn {
    padding: 8px 16px;
    background: #3c3c3c;
    border: 1px solid #0f4ba5;
    border-radius: 4px;
    color: #0f4ba5;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.replace-btn:hover {
    background: #0f4ba5;
    color: #fff;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #3c3c3c;
    border-radius: 20px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #64748b;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #094771;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background: #0f4ba5;
}

/* Results Panel */
.results-content {
    overflow-y: auto;
    padding: 15px;
    background: #ffffff;
}

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5a5a5a;
    text-align: center;
}

.no-results-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-results p {
    font-size: 13px;
}

/* Match Items */
.match-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.match-header {
    padding: 10px 12px;
    background: #edf5ff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.match-header:hover {
    background: #e2e8f0;
}

.match-number {
    font-size: 12px;
    font-weight: 600;
    color: #0f4ba5;
    min-width: 24px;
}

.match-text {
    flex: 1;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    color: #ce9178;
    margin: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-position {
    font-size: 11px;
    color: #64748b;
}

.match-toggle {
    color: #64748b;
    font-size: 10px;
    margin-left: 8px;
}

.match-details {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: none;
}

.match-item.expanded .match-details {
    display: block;
}

.match-item.expanded .match-toggle {
    transform: rotate(180deg);
}

.detail-row {
    display: flex;
    padding: 4px 0;
    font-size: 12px;
}

.detail-label {
    color: #64748b;
    min-width: 80px;
}

.detail-value {
    color: #d4d4d4;
    font-family: 'Consolas', monospace;
}

.detail-value.group-0 { color: #ce9178; }
.detail-value.group-1 { color: #4ec9b0; }
.detail-value.group-2 { color: #9cdcfe; }
.detail-value.group-3 { color: #dcdc78; }
.detail-value.group-4 { color: #c586c0; }
.detail-value.group-5 { color: #b5cea8; }

/* Replace Result */
.result-output {
    width: 100%;
    height: 100%;
    padding: 15px;
    background: #ffffff;
    border: none;
    color: #d4d4d4;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.modal-close {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
}

::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4e4e52;
}

/* Responsive */
@media (max-width: 1200px) {
    .content-area {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .test-panel {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        min-height: 200px;
    }

    .results-panel {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
        min-height: 250px;
    }

    .replace-panel {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
    }

    .replace-result-panel {
        grid-column: 1 / 2;
        grid-row: 4 / 5;
    }

    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .sidebar-section {
        display: none;
    }

    .sidebar-section:first-of-type {
        display: block;
    }

    .regex-header {
        flex-wrap: wrap;
    }

    .flags-section {
        flex-wrap: wrap;
    }

    .content-area {
        padding: 10px;
        gap: 10px;
    }
}
