/* ============================================================
   CodeLens — Editor styling
   ============================================================ */

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-code: #0d0d1a;
    --border: #2a2a4a;
    --text: #e0e0e0;
    --text-muted: #75715e;
    --html: #e94560;
    --css: #53d8fb;
    --js: #fd971f;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, sans-serif; }

body {
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

/* ====== HEADER ====== */
.header {
    background: var(--bg-card);
    padding: 10px 25px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 10px;
}
.header .brand { color: var(--html); font-size: 1.3rem; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.header .brand span { color: var(--css); font-weight: 300; font-size: 0.9rem; }

.header .nav-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.header .nav-links a {
    color: #c4c4d4;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 6px;
    transition: all 0.3s;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.header .nav-links a:hover { background: #2a3a5e; color: #fff; }
.header .nav-links a.active { background: #2a3a5e; color: var(--html); }

.project-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(166, 226, 46, 0.1);
    border: 1px solid rgba(166, 226, 46, 0.3);
    color: #a6e22e;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
}
.project-indicator strong { font-family: 'Courier New', monospace; direction: ltr; color: #fff; }

.btn-project-selector {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(108, 92, 231, 0.1));
    color: #a29bfe;
    border: 1px solid rgba(108, 92, 231, 0.4);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.3s;
}
.btn-project-selector:hover {
    background: rgba(108, 92, 231, 0.3);
    color: #fff;
    transform: translateY(-1px);
}

.container-main { padding: 15px; max-width: 1600px; margin: 0 auto; }

/* ====== TOOLBAR ====== */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    align-items: center;
}
.toolbar .btn {
    padding: 6px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.toolbar .btn-primary { background: var(--html); color: #fff; }
.toolbar .btn-primary:hover { background: #c73652; }
.toolbar .btn-success { background: var(--css); color: var(--bg-dark); }
.toolbar .btn-success:hover { background: #3ac0e0; }
.toolbar .btn-info { background: #17a2b8; color: #fff; }
.toolbar .btn-info:hover { background: #138496; }
.toolbar .btn-undo { background: var(--js); color: var(--bg-dark); }
.toolbar .btn-undo:hover { background: #e0861a; }
.toolbar .btn-history { background: #a6e22e; color: var(--bg-dark); }
.toolbar .btn-history:hover { background: #8cc41a; }
.toolbar .btn-reset-full { background: #ff6b6b; color: #fff; }
.toolbar .btn-reset-full:hover { background: #e05555; }
.toolbar .btn-outline { background: transparent; color: #c4c4d4; border: 1px solid var(--border); }
.toolbar .btn-outline:hover { background: #2a3a5e; color: #fff; }
.toolbar .status { color: var(--text-muted); font-size: 0.8rem; margin-left: auto; display: flex; align-items: center; gap: 10px; }
.toolbar .status .saved { color: var(--css); }

/* ===== RESET-KNAPP I PANEL-HEADER ===== */
.btn-reset-panel {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
    font-family: inherit;
    border: 1px solid rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    transition: all 0.25s;
}

.btn-reset-panel:hover {
    background: #ff6b6b;
    color: #fff;
    transform: rotate(-90deg);
}

/* ====== PANELER ====== */
.panel-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 15px; }

.panel-item {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.3s;
}

.panel-header {
    padding: 10px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 2px solid transparent;
}

.panel-header .label {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-header .label.html { color: var(--html); }
.panel-header .label.css { color: var(--css); }
.panel-header .label.js { color: var(--js); }

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

.btn-eye {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
    font-family: inherit;
    border: 1px solid;
    transition: all 0.25s;
}
.html-panel .btn-eye { background: rgba(233, 69, 96, 0.1); border-color: rgba(233, 69, 96, 0.3); color: var(--html); }
.html-panel .btn-eye:hover { background: var(--html); color: #fff; }
.css-panel .btn-eye { background: rgba(83, 216, 251, 0.1); border-color: rgba(83, 216, 251, 0.3); color: var(--css); }
.css-panel .btn-eye:hover { background: var(--css); color: var(--bg-dark); }
.js-panel .btn-eye { background: rgba(253, 151, 31, 0.1); border-color: rgba(253, 151, 31, 0.3); color: var(--js); }
.js-panel .btn-eye:hover { background: var(--js); color: var(--bg-dark); }

.toggle-icon {
    color: var(--text-muted);
    font-size: 1rem;
    transition: transform 0.3s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
}
.toggle-icon:hover { background: rgba(255,255,255,0.05); }
.toggle-icon.open { transform: rotate(180deg); }

.panel-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}
.panel-item.open .panel-body { max-height: 400px; }
.panel-item.open .panel-header { border-bottom-color: var(--border); }
.html-panel.open .panel-header { border-bottom-color: var(--html); }
.css-panel.open .panel-header { border-bottom-color: var(--css); }
.js-panel.open .panel-header { border-bottom-color: var(--js); }

.CodeMirror {
    height: 250px !important;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-code) !important;
}
.CodeMirror-gutters { background: var(--bg-code) !important; border-right: 1px solid var(--border) !important; }
.CodeMirror-linenumber { color: var(--text-muted) !important; }

/* ====== PREVIEW ====== */
.preview-container {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    height: 450px;
    position: relative;
}
.preview-container iframe { width: 100%; height: 100%; border: none; background: #fff; }
.preview-label {
    position: absolute;
    top: 10px;
    right: 15px;
    background: rgba(26, 26, 46, 0.8);
    color: var(--text-muted);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.7rem;
    pointer-events: none;
    backdrop-filter: blur(5px);
}

/* ====== MODAL ====== */
.modal-overlay, .project-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.show, .project-modal-overlay.show { display: flex; }

.modal-content, .project-modal {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 750px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}
.modal-header, .project-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3, .project-modal-header h3 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--css);
    display: flex;
    align-items: center;
    gap: 8px;
}
.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
    transition: all 0.3s;
    line-height: 1;
}
.close-btn:hover { color: var(--html); transform: rotate(90deg); }
.modal-body, .project-modal-body { padding: 15px 20px; flex: 1; overflow: auto; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.btn-close-modal {
    background: var(--border);
    color: var(--text);
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.btn-close-modal:hover { background: #3a4a6e; }

/* Project cards */
.project-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.project-modal-card {
    background: var(--bg-code);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 20px 18px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.project-modal-card:hover {
    border-color: #6c5ce7;
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(108, 92, 231, 0.25);
}
.project-modal-card.active {
    border-color: #a6e22e;
    background: linear-gradient(160deg, var(--bg-code), rgba(166, 226, 46, 0.08));
}
.pm-active-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #a6e22e;
    color: var(--bg-dark);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}
.pm-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(108, 92, 231, 0.15);
    color: #a29bfe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.project-modal-card h4 {
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    direction: ltr;
    text-align: right;
    margin: 0;
}
.pm-files { display: flex; gap: 6px; }
.pm-file-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.pm-file-dot.present { background: #a6e22e; box-shadow: 0 0 8px rgba(166, 226, 46, 0.6); }
.pm-file-dot.missing { background: rgba(117, 113, 94, 0.4); }

/* History */
.history-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.history-item .info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.history-item .version-badge {
    background: var(--bg-code);
    padding: 1px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    color: var(--css);
    width: fit-content;
}
.history-item .date { color: var(--text-muted); font-size: 0.75rem; }
.history-item .actions { display: flex; gap: 5px; }
.history-item .actions button {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.3s;
}
.history-item .actions .restore-btn { background: var(--css); color: var(--bg-dark); }
.history-item .actions .delete-btn { background: var(--html); color: #fff; }

.empty-history { text-align: center; color: var(--text-muted); padding: 40px 20px; }

/* ============================================================
   HISTORIKK — slett-knapp
   ============================================================ */

.history-item {
    padding: 12px 15px;
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.history-item .info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 150px;
}

.history-item .version-badge {
    background: rgba(83, 216, 251, 0.15);
    color: #53d8fb;
    padding: 3px 12px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    width: fit-content;
}

.history-item .date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.history-item .preview {
    color: #c4c4d4;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 400px;
}

.history-item .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-restore {
    padding: 6px 14px;
    background: #a6e22e;
    color: var(--bg-dark);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.25s;
}

.btn-restore:hover {
    background: #8cc41a;
    transform: translateY(-1px);
}

/* 🗑️ SLEtt-KNAPP */
.btn-delete-version {
    padding: 6px 12px;
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.25s;
}

.btn-delete-version:hover {
    background: #e94560;
    color: #fff;
    transform: translateY(-1px);
}

/* Modal-footer for delete all */
.history-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.history-modal-footer .info-text {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-delete-all {
    padding: 10px 20px;
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
}

.btn-delete-all:hover {
    background: #e94560;
    color: #fff;
    transform: translateY(-1px);
}

/* ====== FULLSCREEN ====== */
.fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-code);
    z-index: 999999;
    flex-direction: column;
}
.fullscreen-overlay.show { display: flex; }

/* ======    FULLSKJERM-OVERLAY   ====== */

.fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-code);
    z-index: 999999;
    flex-direction: column;
}

.fullscreen-overlay.show {
    display: flex;
}

/* Header */
.fs-header {
    background: var(--bg-card);
    padding: 15px 25px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}

.fs-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 700;
}

.fs-title i {
    font-size: 1.4rem;
}

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

.fs-action-btn {
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
}

.fs-btn-save {
    background: #a6e22e;
    color: #1a1a2e;
}
.fs-btn-save:hover {
    background: #8cc41a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(166, 226, 46, 0.4);
}

.fs-btn-copy {
    background: rgba(83, 216, 251, 0.15);
    color: #53d8fb;
    border: 1px solid rgba(83, 216, 251, 0.3);
}
.fs-btn-copy:hover {
    background: #53d8fb;
    color: #1a1a2e;
    transform: translateY(-2px);
}

.fs-btn-close {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.3);
}
.fs-btn-close:hover {
    background: #e94560;
    color: #fff;
    transform: translateY(-2px);
}

/* Editor container */
.fs-editor-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-code);
    min-height: 0;
}

.fs-editor-container .CodeMirror {
    height: 100% !important;
    width: 100% !important;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    line-height: 1.8;
    background: var(--bg-code) !important;
    direction: ltr;
    text-align: left;
}

.fs-editor-container .CodeMirror-gutters {
    background: var(--bg-code) !important;
    border-right: 1px solid var(--border) !important;
    padding-right: 10px;
}

.fs-editor-container .CodeMirror-linenumber {
    color: var(--text-muted) !important;
    font-size: 13px;
}

.fs-editor-container .CodeMirror-lines {
    padding: 20px 0;
}

.fs-editor-container .CodeMirror-cursor {
    border-left: 2px solid #f8f8f2 !important;
}

/* Footer */
.fs-footer {
    background: var(--bg-card);
    padding: 12px 25px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.fs-footer i {
    color: var(--css);
}

.fs-counters {
    display: flex;
    gap: 20px;
    font-family: 'Courier New', monospace;
    color: var(--css);
    font-weight: 600;
}

/* Responsiv */
@media (max-width: 768px) {
    .fs-header {
        padding: 12px 15px;
    }
    .fs-title {
        font-size: 0.95rem;
    }
    .fs-action-btn {
        padding: 7px 12px;
        font-size: 0.78rem;
    }
    .fs-editor-container .CodeMirror {
        font-size: 13px;
    }
    .fs-footer {
        padding: 10px 15px;
        font-size: 0.75rem;
    }
    .fs-counters {
        gap: 12px;
    }
}

.fs-header {
    background: var(--bg-card);
    padding: 15px 25px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.fs-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 700;
}
.fs-title.html { color: var(--html); }
.fs-title.css { color: var(--css); }
.fs-title.js { color: var(--js); }

.fs-actions { display: flex; gap: 8px; }
.fs-action-btn {
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
}
.fs-btn-save { background: #a6e22e; color: var(--bg-dark); }
.fs-btn-save:hover { background: #8cc41a; }
.fs-btn-close { background: rgba(233, 69, 96, 0.15); color: var(--html); border: 1px solid rgba(233, 69, 96, 0.3); }
.fs-btn-close:hover { background: var(--html); color: #fff; }

.fs-editor-container { flex: 1; overflow: hidden; min-height: 0; }
.fs-editor-container .CodeMirror { height: 100% !important; font-size: 15px; }

/* ====== TOAST ====== */
.toast-message, .toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #2a3a5e;
    color: var(--text);
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    z-index: 99999;
    animation: slideUp 0.3s ease;
    max-width: 450px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    font-size: 0.9rem;
}
.toast-message.success, .toast.success { background: #2d5a4e; }
.toast-message.error, .toast.error { background: #5a2a4e; }
.toast-message.warning { background: #5a4a2e; }
.toast-message.info, .toast.info { background: #2a4a5e; }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .header { flex-direction: column; align-items: flex-start; }
    .container-main { padding: 10px; }
    .CodeMirror { height: 180px !important; font-size: 12px; }
    .preview-container { height: 300px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .status { margin-left: 0; }
    .project-modal-grid { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 6px; background: var(--bg-code); }
::-webkit-scrollbar-thumb { background: #3a4a6e; border-radius: 8px; }