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

body {
    background-color: #ffffff;
    color: #000000;
    font-family: 'Georgia', serif; /* Academic feel */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
nav {
    height: 60px;
    border-bottom: 2px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-family: 'Arial', sans-serif;
}
.logo { font-weight: 900; letter-spacing: 2px; font-size: 1.2rem; }
.status { font-size: 0.8rem; color: #666; font-style: italic; }
.logout { text-decoration: none; color: #000; font-weight: bold; border: 1px solid #000; padding: 5px 10px; }

/* LAYOUT */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

aside {
    width: 250px;
    padding: 20px;
    border-right: 1px solid #ccc;
    background: #f9f9f9;
    font-family: 'Arial', sans-serif;
}
.sidebar-right {
    border-left: 1px solid #ccc;
    border-right: none;
    background: #fff;
}

h3 { font-size: 0.8rem; margin-bottom: 15px; text-transform: uppercase; border-bottom: 1px solid #000; padding-bottom: 5px; }

/* EDITOR */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}
textarea {
    flex: 1;
    width: 100%;
    padding: 40px;
    font-size: 1.1rem;
    line-height: 1.6;
    border: none;
    resize: none;
    outline: none;
    font-family: 'Georgia', serif;
}

/* OUTPUT BOX */
#ai-output {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #333;
}

/* DOCK BUTTONS */
.dock {
    height: 60px;
    border-top: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
}
button {
    background: #fff;
    border: 1px solid #000;
    color: #000;
    padding: 8px 15px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.7rem;
    transition: all 0.2s;
}
button:hover {
    background: #000;
    color: #fff;
}
.save-btn { border: 2px solid #000; }
/* DOCK UPGRADE */
.dock-wrapper {
    border-top: 2px solid #000;
    background: #f4f4f4;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dock-label {
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 1px;
    color: #666;
    text-transform: uppercase;
}

.dock-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 buttons per row */
    gap: 8px;
}

.dock-grid button {
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
    padding: 10px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.dock-grid button:hover {
    background: #000;
    color: #fff;
    border-color: #000;
    transform: translateY(-2px);
}

.dock-actions {
    margin-top: 5px;
    display: flex;
    justify-content: flex-end;
}

.save-btn {
    background: #000;
    color: #fff;
    border: none;
    padding: 10px 20px;
    font-weight: 900;
    letter-spacing: 1px;
}

.save-btn:hover {
    background: #333;
}
/* LEFT SIDEBAR UPGRADE */
.sidebar-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f4f4f4;
    border-right: 2px solid #000;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    flex: 1; /* Split height 50/50 */
    overflow: hidden;
}

/* CHAPTER LIST */
.list-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ccc;
    background: #fff;
}

.chapter-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
    transition: background 0.2s;
}

.chapter-item:hover {
    background: #e0e0e0;
    color: #000;
}

.chapter-item.active {
    background: #000;
    color: #fff;
}

/* REFERENCE READER */
.ref-controls {
    margin-bottom: 5px;
}

input[type="file"] {
    display: none; /* Hide ugly default input */
}

.upload-btn {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px dashed #666;
    text-align: center;
    padding: 8px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
}

.upload-btn:hover {
    background: #000;
    color: #fff;
    border-style: solid;
}

#reference-viewer {
    flex: 1;
    resize: none;
    border: 1px solid #ccc;
    padding: 10px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace; /* Monospace for data */
    background: #fff;
    color: #555;
    outline: none;
}
/* RESIZER HANDLES */
.resizer {
    width: 5px;
    background: #ccc;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 10;
}

.resizer:hover, .resizer.dragging {
    background: #000; /* Turns black when you grab it */
    width: 5px;
}

/* PREVENT TEXT SELECTION WHILE DRAGGING */
body.resizing {
    cursor: col-resize;
    user-select: none; /* Important! Stops text highlighting */
}

/* ENSURE PANELS DON'T CRUSH */
.sidebar-left { min-width: 150px; max-width: 500px; }
.sidebar-right { min-width: 200px; max-width: 600px; }
.editor-area { min-width: 400px; }
/* RIGHT SIDEBAR LAYOUT */
.sidebar-right {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #ccc;
}

.observer-section {
    flex: 2; /* Takes up 2/3 of space */
    padding: 15px;
    overflow-y: auto;
    border-bottom: 2px solid #000;
}

.metrics-section {
    flex: 1; /* Takes up 1/3 of space */
    padding: 15px;
    background: #f9f9f9;
}

/* AI TEXT STYLING */
.markdown-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #333;
}
.markdown-body h1, .markdown-body h2 { font-size: 1rem; font-weight: bold; margin-top: 10px; }
.markdown-body ul { padding-left: 20px; }

/* PROGRESS BARS (Monochrome) */
.metric-row { margin-bottom: 15px; }

.metric-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 5px;
    color: #555;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: #e0e0e0; /* Light Gray Background */
    border: 1px solid #999;
}

.progress-fill {
    height: 100%;
    background: #000; /* Solid Black Fill */
    transition: width 0.5s ease-in-out;
}
.scaffold-btn {
    width: 100%;
    background: #000;
    color: #fff;
    border: none;
    padding: 8px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}

.scaffold-btn:hover {
    background: #444;
}
.chapter-row:hover {
    background-color: #f0f0f0;
}
.chapter-item.active {
    background-color: #000 !important;
    color: #fff !important;
}
/* --- RIGHT SIDEBAR TABS --- */
.sidebar-tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 15px;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    color: #666;
}
.tab-btn.active {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
}
.full-width {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
/* --- ZETTEL CARDS --- */
.zettel-card {
    background: white;
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.9em;
}
.zettel-title { font-weight: bold; color: #2c3e50; }
.zettel-tags { color: #3498db; font-size: 0.8em; }
.zettel-source { color: #7f8c8d; font-style: italic; font-size: 0.8em; }
.zettel-body { margin-top: 5px; color: #333; }
.delete-zettel { color: red; float: right; cursor: pointer; }
/* --- CUSTOM RIGHT-CLICK MENU --- */
.context-menu {
    position: absolute;
    z-index: 1000;
    width: 180px;
    background: #2d3436;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    border: 1px solid #444;
    overflow: hidden;
}

.context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.context-menu li {
    padding: 10px 15px;
    cursor: pointer;
    color: #ecf0f1;
    font-size: 14px;
    transition: background 0.2s;
}

.context-menu li:hover {
    background: #3498db;
    color: white;
}
/* --- FORENSIC REPORT STYLING --- */

/* The main container for the AI's diagnosis */
.forensic-report {
    border: 1px solid #000;
    padding: 15px;
    background: #fafafa;
    margin-bottom: 20px;
}

/* The "Human vs Robot" Percentage Gauge */
.probability-score {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    background: #000; /* Black background for contrast */
    padding: 12px;
    text-align: center;
    border-radius: 2px;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

/* Red Flags for AI Lexicon words */
.flag-header {
    font-family: monospace;
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 5px;
    border-bottom: 1px solid #ddd;
}

.flag-list {
    color: #d00000; /* Deep warning red */
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

/* The Verdict/Instruction section */
.forensic-verdict {
    background: #eee;
    padding: 10px;
    border-left: 4px solid #000;
    font-style: italic;
    font-size: 0.85rem;
}
/* 1. Make the Div look like a Editor */
#main-editor {
    width: 100%;
    height: 600px;
    padding: 25px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Georgia', serif; /* PhD Academic Font */
    font-size: 1.1rem;
    line-height: 1.8;
    overflow-y: auto;
    background: #ffffff;
    outline: none; /* Removes the blue browser glow */
}

/* 1. The Red Highlight (Base Style) */
.ai-word {
    border-bottom: 2px solid #d00000;
    background-color: rgba(255, 0, 0, 0.1);
    cursor: help;
    position: relative; /* Anchor for the tooltip */
}

/* 2. The Tooltip Box (Hidden by default) */
.ai-word:hover::after {
    content: "⚠️ AI Cliché Detected";
    position: absolute;
    bottom: 120%; /* Sits above the word */
    left: 50%;
    transform: translateX(-50%); /* Centers it */
    
    background: #222;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: sans-serif;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 100;
    pointer-events: none; /* Lets you click through it */
}

/* 3. The Little Arrow (Pointing down) */
.ai-word:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #222 transparent transparent transparent;
}
.suggestion-item:hover {
    background: #f0f0f0;
    border-left: 2px solid #000 !important;
}
/* --- PHRASE INJECTION UI --- */

#phrase-suggestions-overlay {
    /* This ensures the scrollbar matches your app's style */
    scrollbar-width: thin;
    scrollbar-color: #000 #fff;
}

.suggestion-item {
    cursor: pointer;
    padding: 10px;
    margin-bottom: 5px;
    border-left: 2px solid #eee;
    font-size: 0.85rem;
    line-height: 1.4;
    transition: all 0.2s ease-in-out;
}

.suggestion-item:hover {
    background: #f4f4f4;
    border-left: 2px solid #000;
    padding-left: 15px; /* Slight 'nudge' effect on hover */
}

/* Category headers inside the phrase bank */
#suggestions-content strong {
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    border-bottom: 1px solid #000;
    padding-bottom: 2px;
}
@keyframes pulse-refine {
    0% { opacity: 0.5; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1); color: #007bff; }
    100% { opacity: 0.5; transform: scale(0.98); }
}

.refining-status {
    animation: pulse-refine 1.2s infinite ease-in-out;
    font-weight: 600;
    font-size: 0.9rem;
}
/* --- GRAMMARLY-STYLE HIGHLIGHTS --- */

/* The Target: The word itself */
.ai-cliche {
    text-decoration: underline wavy #ff4444; /* Red squiggly line */
    text-decoration-skip-ink: none;
    cursor: help;
    position: relative; /* Needed for the tooltip anchor */
}

/* The Tooltip: Appears on hover */
.ai-cliche:hover::after {
    content: "⚠️ AI Cliché: " attr(data-suggestion); /* Magically pulls text */
    position: absolute;
    bottom: 120%; /* Sits above the word */
    left: 50%;
    transform: translateX(-50%); /* Centers it */
    
    background-color: #222;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border: 1px solid #444;
}

/* Optional: Tiny arrow pointing down */
.ai-cliche:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #222 transparent transparent transparent;
}
/* --- CITATION WATCHDOG --- */

.uncited-warning {
    background-color: rgba(255, 235, 59, 0.15); /* Light Yellow Background */
    border-left: 3px solid #fbc02d; /* Solid Yellow Bar on left */
    position: relative;
    cursor: help;
}

.uncited-warning:hover::after {
    content: "⚠️ UNSOURCED: This paragraph has no citations.";
    position: absolute;
    top: -30px;
    left: 10px;
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
}
/* --- CLARITY RADAR --- */

.clarity-error {
    background-color: rgba(156, 39, 176, 0.1); /* Light Purple */
    border-bottom: 2px dashed #9c27b0; /* Purple dashed underline */
    cursor: help;
}

.clarity-error:hover::after {
    content: "⚠️ COMPLEXITY: This sentence is very long. Consider breaking it up for clarity.";
    position: absolute;
    background: #333;
    color: #fff;
    padding: 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 1000;
}
/* --- LOGIC GAP HIGHLIGHTER --- */

.logic-gap {
    background-color: rgba(33, 150, 243, 0.1); /* Light Blue */
    border-left: 4px solid #2196f3; /* Strong blue bar */
    position: relative;
    cursor: help;
    padding-left: 5px;
}

.logic-gap:hover::after {
    content: "⚠️ LOGICAL LEAP: You are concluding here, but did you provide evidence in the previous sentence?";
    position: absolute;
    top: -35px;
    left: 0;
    background: #111;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 1000;
    white-space: nowrap;
}
/* Container: Clean, jet-black bar */
.sidebar-tabs {
    display: flex;
    background: #000;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
    padding: 5px 0;
}

/* The Buttons: Transparent and seamless */
.tab-btn {
    flex: 1;
    background: transparent !important;
    border: none;
    cursor: pointer;
    font-size: 1.4rem; /* Slightly larger for clarity */
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    opacity: 0.4; /* Faded when inactive */
    filter: grayscale(100%);
}

/* Hover: Bring back the color and brightness */
.tab-btn:hover {
    opacity: 0.8;
    filter: grayscale(0%);
    transform: translateY(-2px);
}

/* ACTIVE STATE: The "Laser focus" look */
.tab-btn.active {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1.1);
}

/* The Floating Underline Indicator (The 'Pro' Move) */
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 30%; /* Narrow and elegant */
    height: 2px;
    background: #fff;
    box-shadow: 0 0 10px #fff; /* Neon white glow */
    border-radius: 10px;
    transition: all 0.3s ease;
}

/* Active Icon Glow */
.tab-btn.active {
    animation: socratesGlow 3s infinite ease-in-out;
}

@keyframes socratesGlow {
    0% { filter: drop-shadow(0 0 1px rgba(255,255,255,0.2)); }
    50% { filter: drop-shadow(0 0 8px rgba(255,255,255,0.6)); }
    100% { filter: drop-shadow(0 0 1px rgba(255,255,255,0.2)); }
}