/* ===== DIFFwriter Styles ===== */

/* Theme Variables - Consolidated background and surface */
:root,
[data-theme="dark"] {
    --bg-color: #1a1d23;
    --surface: #1a1d23;
    /* Consolidated with bg-color */
    --border: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --success: #3fb950;
    --button-hover: rgba(56, 139, 253, 0.15);
    --ui-font-size: 13px;
}

/* Light Mode Variables */
[data-theme="light"] {
    --bg-color: #f6f8fa;
    --surface: #f6f8fa;
    /* Consolidated with bg-color */
    --border: #d0d7de;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --accent: #0969da;
    --button-hover: rgba(9, 105, 218, 0.1);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: var(--text-primary);
    overflow: hidden;
    position: relative;
}

/* Subtle texture for dark theme */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

body>* {
    position: relative;
    z-index: 2;
}

/* Top Bar Floating */
.top-deck {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    background: rgba(22, 27, 34, 0.85);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0 24px 0 0;
    /* Remove top/bottom and left padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    height: 48px;
    /* Fixed height for filling */
    overflow: hidden;
}

.logo {
    font-weight: 600;
    font-size: 20px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;
}

.app-logo {
    height: 100%;
    width: 48px;
    object-fit: cover;
    border-radius: 16px 0 0 16px;
    margin-right: 12px;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-magic {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-magic:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.3);
}

/* Editor Area */
.workspace {
    display: flex;
    height: 100vh;
    padding-top: 80px;
    box-sizing: border-box;
    gap: 2px;
}

.editor-pane {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: rgba(13, 17, 23, 0.5);
}

.divider {
    width: 4px;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.3s;
}

.divider:hover {
    background: var(--accent);
}

/* Toolbars */
.toolbar-container {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.doc-toolbar {
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.md-toolbar {
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(13, 17, 23, 0.4);
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
}

.format-toolbar {
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(13, 17, 23, 0.3);
}

.doc-title {
    font-size: var(--ui-font-size);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
}

.tool-group {
    display: flex;
    gap: 8px;
}

.tool-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--icon-color, var(--text-secondary));
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--ui-font-size);
    font-family: 'Outfit', sans-serif;
}

.tool-btn .material-icons-round {
    color: var(--icon-color, var(--text-secondary));
}

.tool-btn:hover {
    background: var(--button-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Format Buttons */
.fmt-btn {
    background: transparent;
    border: none;
    color: var(--icon-color, var(--text-secondary));
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--ui-font-size);
    font-weight: 600;
}

.fmt-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.fmt-group,
.fmt-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: transparent;
    border-radius: 6px;
}

.fmt-group:last-child,
.fmt-bar:last-child {
    margin-right: 0;
}

/* Editor Content */
.scroller {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px 40px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    background-color: #0d1117;
    text-align: center;
}

/* Double Paper for Swap */
.paper-container {
    width: 100%;
    margin: 0 auto;
    position: relative;
    /* Ensure child overlays are positioned correctly */
    min-height: 100%;
}

.paper {
    background-color: white;
    color: #202124;
    width: 100%;
    min-height: 1056px;
    padding: 60px;
    box-sizing: border-box;
    line-height: 1.6;
    font-size: 15px;
    text-align: left;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    font-family: 'Roboto', sans-serif;
    display: none;
}

.paper.active {
    display: block;
}

/* Remove default heading margins in preview */
.paper h1,
.paper h2,
.paper h3,
.paper h4,
.paper h5,
.paper h6,
.paper p,
.paper ul,
.paper ol,
.paper li {
    margin: 0;
    padding: 0;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #1a2f1a 0%, #0d1a0d 100%);
    border: 2px solid #2d5f2d;
    color: #e8f5e8;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(45, 95, 45, 0.3);
    z-index: 10000;
    min-width: 400px;
    max-width: 600px;
    animation: fadeInScale 0.3s ease-out;
    backdrop-filter: blur(10px);
}

.toast-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(45, 95, 45, 0.3);
}

.toast-icon {
    width: 32px;
    height: 32px;
    background: #2d5f2d;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4ade80;
    font-size: 18px;
}

.toast-title {
    font-size: 16px;
    font-weight: 700;
    color: #4ade80;
    letter-spacing: 0.5px;
}

.toast-body {
    font-size: 14px;
    line-height: 1.6;
    color: #c9e4c9;
    margin-bottom: 16px;
}

.toast-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid rgba(45, 95, 45, 0.3);
}

.toast-button {
    background: #4ade80;
    color: #0d1a0d;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toast-button:hover {
    background: #22c55e;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(74, 222, 128, 0.3);
}

.toast-button:active {
    transform: translateY(0);
}

.toast.success {
    border-color: #4ade80;
    box-shadow: 0 8px 32px rgba(74, 222, 128, 0.2), 0 0 0 1px rgba(74, 222, 128, 0.3);
}

.toast.success .toast-icon {
    background: #4ade80;
    color: #0d1a0d;
}

.toast.info {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #1a2a3f 0%, #0d1520 100%);
}

.toast.info .toast-icon {
    background: #3b82f6;
    color: #0d1520;
}

.toast.info .toast-title {
    color: #60a5fa;
}

@keyframes fadeInScale {
    from {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes fadeOutScale {
    from {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    to {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
    }
}

/* Raw Markdown View */
.paper-raw {
    background-color: #0d1117;
    color: #c9d1d9;
    border: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
    display: none;
}

.paper-raw.active {
    display: block;
}

/* View Toggle */
.view-switch {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 2px;
    gap: 2px;
}

.view-opt {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    color: var(--icon-color, var(--text-secondary));
    display: flex;
    align-items: center;
}

.view-opt.selected {
    background: var(--border);
    color: white;
}

.paper ::selection {
    background: #b3d7ff;
}

/* Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #30363d;
    border-radius: 34px;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: #8b949e;
    border-radius: 50%;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    background-color: white;
    transform: translateX(14px);
}

/* Selection visibility - different colors for RAW and VISUAL */
.paper-raw::selection {
    background: #4a5568;
    color: #f0f6fc;
}

.paper::selection {
    background: #e2e8f0;
    color: #202124;
}

/* Keep selection visible even when unfocused */
.paper-raw:not(:focus)::selection {
    background: rgba(74, 85, 104, 0.6);
}

.paper:not(:focus)::selection {
    background: rgba(226, 232, 240, 0.6);
}

/* Visual indicator overlays for unfocused editor */
.selection-overlay {
    position: absolute;
    background: rgba(88, 166, 255, 0.4);
    pointer-events: none;
    z-index: 5;
    border-radius: 2px;
}

.cursor-overlay {
    position: absolute;
    width: 2px;
    background-color: var(--accent);
    pointer-events: none;
    z-index: 10;
    animation: blink 1s step-end infinite;
}

/* Cursor blink animation */
@keyframes blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

/* Action Bridge (Central controls) */
.action-bridge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 4px;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.bridge-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.bridge-btn:hover {
    color: var(--accent);
    background: var(--button-hover);
}

.bridge-btn .material-icons-round {
    font-size: 20px;
}

.bridge-label {
    font-size: 9px;
    font-weight: 700;
}

/* Floating Toolbar (Contextual) */
.floating-toolbar {
    position: fixed;
    display: none;
    flex-direction: column !important;
    background: rgba(22, 27, 34, 0.95);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    align-items: center;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: popIn 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
    from {
        transform: translateY(10px) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.floating-toolbar.active {
    display: flex;
}

.floating-toolbar.raw-only .visual-only {
    display: none;
}

.fmt-row {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.fmt-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.file-name {
    font-size: 14px;
    color: var(--text-primary);
}

.file-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Settings Panel */
.settings-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 300px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-panel.active {
    display: flex;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.setting-label {
    font-size: var(--ui-font-size);
    color: var(--text-primary);
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.setting-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.setting-input {
    background: #0d1117;
    border: 1px solid var(--border);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    width: 60px;
    font-family: inherit;
}

.setting-select {
    background: #0d1117;
    border: 1px solid var(--border);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
}

/* Auto-save rotation animation */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.rotating {
    animation: rotate 2s linear infinite;
}

/* Theme Buttons */
.theme-btn {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.theme-btn:hover {
    background: var(--button-hover);
    border-color: var(--accent);
}

.theme-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Settings Panel Sections */
.setting-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    margin-top: 0;
}

/* Aggressive spacing reset for settings panel */
.settings-panel>* {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Tighter gap for grouped settings */
}

.settings-panel .setting-row {
    margin: 0 !important;
    padding: 0 !important;
}

.settings-panel .setting-section-title {
    margin-top: 0 !important;
    margin-bottom: 4px !important;
    padding: 4px 0 2px 0 !important;
}

/* Color Pickers */
.color-picker {
    width: 60px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: var(--surface);
    padding: 0;
    margin: 0;
    display: block;
}

/* Sliders */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.setting-slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.setting-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Settings Panel Scrolling */
.settings-panel::-webkit-scrollbar {
    width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
    background: var(--surface);
}

.settings-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.settings-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}