/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

body.dark-theme {
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    color: #e0e0e0;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.dark-theme .header {
    background: rgba(30, 30, 46, 0.9);
    border-bottom: 1px solid #444;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2rem;
    color: #4a6cf7;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(90deg, #4a6cf7, #8a2be2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 0.9rem;
    color: #666;
    margin-left: 0.5rem;
}

.dark-theme .subtitle {
    color: #aaa;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.dark-theme .btn-icon {
    background: #3a3a5a;
    color: #ccc;
}

.dark-theme .btn-icon:hover {
    background: #4a4a6a;
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid #ddd;
    backdrop-filter: blur(8px);
}

.dark-theme .toolbar {
    background: rgba(40, 40, 60, 0.85);
    border-bottom: 1px solid #444;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.separator {
    width: 1px;
    height: 24px;
    background: #ccc;
    margin: 0 0.25rem;
}

.dark-theme .separator {
    background: #555;
}

.btn-tool {
    background: #f8f9fa;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.dark-theme .btn-tool {
    background: #3a3a5a;
    border-color: #555;
    color: #ddd;
}

.dark-theme .btn-tool:hover {
    background: #4a4a6a;
    border-color: #777;
}

.select-tool {
    background: #f8f9fa;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.9rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.select-tool:hover {
    background: #e5e7eb;
}

.dark-theme .select-tool {
    background: #3a3a5a;
    border-color: #555;
    color: #ddd;
}

/* Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px 8px 0 0;
    border: 1px solid #ddd;
    border-bottom: none;
}

.dark-theme .editor-header {
    background: rgba(50, 50, 70, 0.7);
    border-color: #444;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#filename {
    font-weight: 600;
    font-size: 1.1rem;
}

.status-saved {
    color: #10b981;
    font-size: 0.85rem;
    padding: 0.2rem 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 4px;
}

.status-unsaved {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.editor-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: #666;
}

.dark-theme .editor-meta {
    color: #aaa;
}

/* Editor Container */
.editor-container {
    flex: 1;
    position: relative;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    background: #fff;
}

.dark-theme .editor-container {
    border-color: #444;
    background: #1e1e2e;
}

#textEditor {
    width: 100%;
    height: 100%;
    padding: 1rem 1rem 1rem 4rem;
    border: none;
    resize: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: transparent;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow: auto;
}

#textEditor:empty::before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
}

.dark-theme #textEditor {
    color: #e0e0e0;
    background: #1e1e2e;
}

.editor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    display: flex;
}

.line-numbers {
    width: 3.5rem;
    padding: 1rem 0.5rem;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #888;
    background: rgba(240, 240, 240, 0.8);
    border-right: 1px solid #ddd;
    user-select: none;
    line-height: 1.6;
}

.dark-theme .line-numbers {
    background: rgba(40, 40, 60, 0.8);
    border-right: 1px solid #444;
    color: #aaa;
}

.line-numbers div {
    min-height: 1.6em;
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid #ddd;
    font-size: 0.85rem;
    color: #555;
}

.dark-theme .footer {
    background: rgba(30, 30, 46, 0.9);
    border-top: 1px solid #444;
    color: #aaa;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-separator {
    color: #bbb;
}

.footer-right {
    display: flex;
    gap: 0.5rem;
}

.btn-footer {
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-footer:hover {
    background: #f0f0f0;
}

.dark-theme .btn-footer {
    border-color: #555;
    color: #ccc;
}

.dark-theme .btn-footer:hover {
    background: #3a3a5a;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.dark-theme .modal-content {
    background: #2d2d44;
    color: #e0e0e0;
}

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

.dark-theme .modal-header {
    border-bottom: 1px solid #444;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
}

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

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

.modal-body {
    padding: 1.5rem;
}

.setting {
    margin-bottom: 1.5rem;
}

.setting label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.setting input[type="number"],
.setting input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background: #f9f9f9;
}

.dark-theme .setting input {
    background: #3a3a5a;
    border-color: #555;
    color: #fff;
}

.setting input[type="checkbox"] {
    margin-right: 0.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.dark-theme .modal-footer {
    border-top: 1px solid #444;
}

.btn-primary {
    background: #4a6cf7;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #3a5ce5;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.dark-theme .btn-secondary {
    background: #3a3a5a;
    color: #ddd;
    border-color: #555;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.dark-theme .btn-secondary:hover {
    background: #4a4a6a;
}

/* Responsive */
@media (max-width: 1024px) {
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .editor-meta {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .footer-left, .footer-right {
        flex-wrap: wrap;
        justify-content: center;
    }
    .line-numbers {
        width: 2.5rem;
        font-size: 12px;
    }
    #textEditor {
        padding-left: 3rem;
    }
}
/* ── Find & Replace Panel ── */
.find-replace-panel {
    display: none;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #ddd;
    border-bottom: none;
    padding: 0.5rem 1rem;
    gap: 0.4rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 10;
}

.dark-theme .find-replace-panel {
    background: rgba(38, 38, 58, 0.97);
    border-color: #444;
}

.find-replace-panel.active {
    display: flex;
}

.find-row,
.replace-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.find-input-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.find-icon {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 0.8rem;
    pointer-events: none;
}

.find-input-wrap input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color 0.15s;
}

.find-input-wrap input:focus {
    border-color: #4a6cf7;
    box-shadow: 0 0 0 2px rgba(74,108,247,0.15);
}

.dark-theme .find-input-wrap input {
    background: #2a2a42;
    border-color: #555;
    color: #e0e0e0;
}

.dark-theme .find-input-wrap input:focus {
    border-color: #6a8cff;
}

.btn-find {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: #444;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.btn-find:hover {
    background: #e0e0e0;
    border-color: #aaa;
}

.dark-theme .btn-find {
    background: #3a3a5a;
    border-color: #555;
    color: #ccc;
}

.dark-theme .btn-find:hover {
    background: #4a4a6a;
}

.btn-replace-action {
    background: #4a6cf7;
    color: #fff;
    border-color: #3a5ce5;
}

.btn-replace-action:hover {
    background: #3a5ce5;
}

.dark-theme .btn-replace-action {
    background: #4a6cf7;
    color: #fff;
    border-color: #3a5ce5;
}

.btn-close-find {
    background: transparent;
    border-color: transparent;
    color: #888;
}

.btn-close-find:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.dark-theme .btn-close-find:hover {
    background: rgba(220,38,38,0.15);
}

.find-count {
    font-size: 0.82rem;
    color: #888;
    min-width: 60px;
    white-space: nowrap;
}

.dark-theme .find-count { color: #aaa; }

.match-case-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.dark-theme .match-case-label { color: #bbb; }

/* ── Help shortcuts table ── */
.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.shortcuts-table tr {
    border-bottom: 1px solid #eee;
}

.dark-theme .shortcuts-table tr {
    border-bottom: 1px solid #3a3a5a;
}

.shortcuts-table td {
    padding: 0.5rem 0.75rem;
}

.shortcuts-table td:first-child {
    width: 180px;
}

kbd {
    display: inline-block;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.dark-theme kbd {
    background: #2d2d44;
    border-color: #555;
    color: #ddd;
}
