/* === VARIABLES & RESET === */
:root {
    --bg-app: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-panel: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --border: #e5e7eb;
    --sidebar-width: 260px;
    --header-height: 60px;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; outline: none; }
body { margin: 0; font-family: var(--font-sans); background: var(--bg-app); color: var(--text-main); height: 100vh; overflow: hidden; }

/* === LAYOUT STRUCTURE === */
.app-container { display: flex; height: 100vh; width: 100vw; }

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-sidebar); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 50; flex-shrink: 0;
    transition: transform 0.3s ease;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { margin: 0; font-size: 18px; font-weight: 700; color: #111827; }
.version-tag { display: inline-block; font-size: 10px; background: #e0e7ff; color: #3730a3; padding: 2px 6px; border-radius: 4px; margin-top: 5px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 20px 10px; display: flex; flex-direction: column; gap: 5px; }
.nav-item {
    background: transparent; border: none; width: 100%; text-align: left; padding: 12px 15px;
    border-radius: 6px; color: var(--text-muted); font-weight: 500; cursor: pointer;
    display: flex; align-items: center; gap: 10px; transition: all 0.2s; font-size: 14px; font-family: var(--font-sans);
}
.nav-item:hover { background: #f9fafb; color: var(--primary); }
.nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.nav-item .icon { font-size: 18px; }

.sidebar-footer { padding: 15px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.system-status { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; display: inline-block; }

/* === MAIN CONTENT === */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.mobile-header { display: none; padding: 10px 15px; background: white; border-bottom: 1px solid var(--border); justify-content: space-between; align-items: center; }

/* === SECTIONS === */
.view-section { display: none; flex-direction: column; height: 100%; padding: 20px; gap: 15px; overflow-y: auto; }
.view-section.active { display: flex; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; flex-shrink: 0; }
.section-header h3 { margin: 0; font-size: 20px; color: #111827; font-weight: 700; }
.toolbar-actions { display: flex; gap: 10px; }

/* === PANELS & EDITOR GRID === */
.editor-grid { display: flex; gap: 15px; flex: 1; min-height: 0; }
.editor-pane { flex: 1; display: flex; flex-direction: column; background: white; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.pane-bar {
    padding: 10px 15px; background: #f9fafb; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600;
}
.stats-group { display: flex; gap: 6px; }

textarea, .output-div {
    flex: 1; border: none; padding: 15px; font-family: var(--font-sans); font-size: 15px; line-height: 1.6;
    resize: none; color: #374151; width: 100%;
}
.output-div { overflow-y: auto; white-space: pre-wrap; background: #fff; }
.output-div:empty::before { content: attr(data-placeholder); color: #9ca3af; }

/* === SPLIT VIEW LAYOUT === */
.split-controls { display: flex; flex-direction: column; gap: 15px; }
.control-row { display: flex; justify-content: space-between; align-items: center; }
.radio-group { display: flex; gap: 20px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; font-weight: 500; }
.sub-control { background: #f9fafb; padding: 10px; border-radius: 6px; border: 1px solid var(--border); display: flex; align-items: center; gap: 15px; font-size: 13px; }

.segment-selector { display: flex; gap: 4px; }
.seg-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: white; border-radius: 4px; cursor: pointer; font-weight: 600; color: #6b7280; }
.seg-btn:hover { border-color: var(--primary); color: var(--primary); }
.seg-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.split-layout { margin-top: 10px; }
.split-results-grid { flex: 1.5; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; overflow-y: auto; align-content: start; }
.split-box { background: white; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; height: 300px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* === SETTINGS VIEW === */
.settings-container { display: flex; flex-direction: column; height: 100%; max-width: 1000px; margin: 0 auto; width: 100%; }
.panel { background: white; border-radius: 8px; border: 1px solid var(--border); padding: 15px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.mb-4 { margin-bottom: 16px; }
.flex-grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.panel-row.wrap { flex-wrap: wrap; }

.form-select, .form-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.form-input.mono { font-family: var(--font-mono); }
.btn-toggle { padding: 8px 16px; border: 1px solid var(--border); background: #f3f4f6; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.btn-toggle.active { background: #eff6ff; border-color: #93c5fd; color: var(--primary); font-weight: 600; }

.scroll-list-area { flex: 1; overflow-y: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; background: #f9fafb; padding: 10px; }
.punctuation-item { display: flex; gap: 8px; margin-bottom: 8px; padding: 8px; background: white; border: 1px solid var(--border); border-radius: 6px; align-items: center; }
.punctuation-item input { flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; font-family: var(--font-mono); }

/* === BUTTONS & TAGS === */
.btn { border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; font-family: var(--font-sans); display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; } .btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border: 1px solid var(--border); color: #374151; } .btn-secondary:hover { background: #f3f4f6; }
.btn-success { background: #10b981; color: white; } .btn-success:hover { background: #059669; }
.btn-danger { background: #fee2e2; color: #b91c1c; } .btn-danger:hover { background: #ef4444; }
.btn-warning { background: #fef3c7; color: #b45309; }

.badge, .tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px; }
.badge { background: #e5e7eb; color: #4b5563; }
.tag-yellow { background: #fcd34d; color: #78350f; }
.tag-blue { background: #93c5fd; color: #1e3a8a; }

/* === HIGHLIGHTS === */
mark.hl-yellow { background-color: #fef08a; color: black; padding: 0 2px; border-radius: 2px; border-bottom: 2px solid #eab308; }
mark.hl-blue { background-color: #bae6fd; color: black; padding: 0 2px; border-radius: 2px; border-bottom: 2px solid #0ea5e9; }
mark.hl-orange { background-color: #fed7aa; color: black; padding: 0 2px; border-radius: 2px; border-bottom: 2px solid #f97316; }

/* === UTILS === */
.hidden { display: none !important; }
.full-width { width: 100%; }
.input-group { display: flex; gap: 5px; width: 100%; }
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* === NOTIFICATION === */
#notification-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.notification { padding: 12px 20px; border-radius: 6px; background: #1f2937; color: white; font-size: 13px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); animation: slideIn 0.3s ease; }
.notification.error { background: #ef4444; } .notification.success { background: #10b981; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: 0; opacity: 1; } }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); width: 250px; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; flex-shrink: 0; }
    .editor-grid { flex-direction: column; }
    .split-results-grid { grid-template-columns: 1fr; }
    .panel-row { flex-direction: column; align-items: stretch; }
}
