/* ════════════════════════════════════════════════════════
   Çözümle - CSS Variables & Theme (MAXQDA-like modern UI)
   ════════════════════════════════════════════════════════ */

:root {
    /* Light Theme (Default) */
    --bg-main: #f3f4f6;
    --bg-panel: #ffffff;
    --bg-header: #ffffff;
    --bg-hover: #f9fafb;
    
    --border-color: #e5e7eb;
    --divider-color: #f3f4f6;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    --primary: #3b82f6;          /* Blue */
    --primary-hover: #2563eb;
    --success: #10b981;          /* Green */
    --success-hover: #059669;
    --danger: #ef4444;           /* Red */
    --danger-hover: #dc2626;

    /* Shadow & Glass */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --radius: 8px;
    --font-family: 'Inter', sans-serif;
}

body.dark-mode {
    /* Dark Theme */
    --bg-main: #111827;
    --bg-panel: #1f2937;
    --bg-header: #1f2937;
    --bg-hover: #374151;
    
    --border-color: #374151;
    --divider-color: #111827;

    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;

    --primary: #60a5fa;
    --primary-hover: #3b82f6;
}

/* ─── Global Reset & Body ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden; /* App is a fixed dashboard */
}

/* ─── Navbar / Header ─── */
.navbar {
    height: 60px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.badge {
    background-color: var(--primary);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

/* ─── Buttons ─── */
.btn {
    border: none;
    border-radius: var(--radius);
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:not(:disabled):hover { background-color: var(--primary-hover); }

.btn-success { background-color: var(--success); color: white; }
.btn-success:not(:disabled):hover { background-color: var(--success-hover); }

.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:not(:disabled):hover { background-color: var(--danger-hover); }

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:not(:disabled):hover { background-color: var(--bg-hover); }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
}
.btn-icon:hover { background: var(--bg-hover); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.block { width: 100%; display: block; margin-bottom: 16px; }

/* ─── Forms & Inputs ─── */
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-panel);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    margin-bottom: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.input-group {
    background: var(--bg-main);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.hidden { display: none !important; }

/* ─── Workspace Grid ─── */
.workspace {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    height: calc(100vh - 60px);
}

.panel {
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Handled by panel-body */
}

.left-panel, .right-panel {
    border-right: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
}

/* Document List */
.panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ─── Left Panel (Docs) ─── */
.document-list {
    list-style: none;
}

.doc-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.doc-item:hover {
    background-color: var(--bg-hover);
}

.doc-item.active {
    background-color: var(--bg-main);
    border-color: var(--border-color);
    font-weight: 500;
    color: var(--primary);
}

.doc-delete {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0;
    font-size: 1rem;
}
.doc-item:hover .doc-delete { opacity: 1; }

/* ─── Center Panel (Viewer) ─── */
.document-viewer {
    padding: 32px 48px;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 100px;
}

.empty-state h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state.small { margin-top: 20px; font-size: 0.85rem; }

.drop-zone.drag-over {
    border-color: var(--primary) !important;
    background-color: var(--bg-hover) !important;
    transform: scale(1.02);
}

.coding-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-main);
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.form-select-code { margin-bottom: 0; width: 180px; padding: 4px 8px; }
.selection-text { font-size: 0.8rem; font-weight: 600; color: var(--primary); }

/* Highlight CSS */
.coded-text {
    border-bottom: 2px solid var(--mark-border, #fbd38d);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
    cursor: pointer;
    position: relative;
    transition: opacity 0.2s, background-color 0.2s;
}

.coded-text:hover { 
    opacity: 0.8; 
}

.coded-text::after {
    content: attr(data-code);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}
.coded-text:hover::after { opacity: 1; }

/* ─── Right Panel (Codes) ─── */
.add-code-section {
    display: grid;
    grid-template-columns: 1fr 40px 40px;
    gap: 8px;
    margin-bottom: 16px;
}

.color-picker {
    width: 40px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg-panel);
}

.code-list { list-style: none; margin-bottom: 24px; }

.code-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.code-item:hover { border-color: var(--primary); }

.code-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

.code-name { font-size: 0.9rem; font-weight: 500; }

.code-count {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}

.divider {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 20px 0;
}

/* Retrieved Segments */
.retrieval-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.segment-card {
    background: var(--bg-main);
    border-left: 4px solid var(--segment-color, var(--primary));
    padding: 12px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.segment-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

/* ─── Modal & Reports ─── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-panel);
    border-radius: var(--radius);
    width: 650px;
    max-width: 90%;
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px; margin-bottom: 16px;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    z-index: 10000;
    width: 200px;
    padding: 8px 0;
}
.context-menu-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}
.context-menu ul { list-style: none; margin: 0; padding: 0; }
.context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
}
.context-menu li:hover { background: var(--bg-hover); }
.context-menu.hidden { display: none; }
