/* LegalMinds — Professional Dark Theme */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222535;
    --bg-input: #2a2d3a;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --accent-blue: #4a9eff;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --accent-purple: #a78bfa;
    --accent-orange: #fb923c;
    --border-color: #2d3040;
    --sidebar-width: 240px;

    /* Agent colors */
    --agent-orchestrator: #4a9eff;
    --agent-researcher: #34d399;
    --agent-strategist: #f87171;
    --agent-advocate: #a78bfa;
    --agent-psychologist: #fbbf24;
    --agent-paralegal: #fb923c;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────── */

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

#sidebar .logo {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

#sidebar .logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-blue);
    letter-spacing: -0.02em;
}

#sidebar .logo span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.25rem;
}

#sidebar nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

#sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.15s;
}

#sidebar nav a:hover,
#sidebar nav a.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

#sidebar nav a.active {
    color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.1);
}

#sidebar .sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── MAIN CONTENT ───────────────────────────────── */

#main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ─── CARDS ──────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

/* ─── BUTTONS ────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover { opacity: 0.9; }

.btn-danger {
    background: var(--accent-red);
    color: white;
}

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

.btn-secondary:hover { background: var(--bg-card); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ─── FORMS ──────────────────────────────────────── */

input, textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.875rem;
    width: 100%;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > * { flex: 1; }

/* ─── TABLES ─────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ─── BADGES ─────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-green { background: rgba(52, 211, 153, 0.15); color: var(--accent-green); }
.badge-red { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); }
.badge-yellow { background: rgba(251, 191, 36, 0.15); color: var(--accent-yellow); }
.badge-blue { background: rgba(74, 158, 255, 0.15); color: var(--accent-blue); }
.badge-purple { background: rgba(167, 139, 250, 0.15); color: var(--accent-purple); }
.badge-orange { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }

/* ─── DEADLINES ──────────────────────────────────── */

.deadline-urgent { border-left: 3px solid var(--accent-red); }
.deadline-soon { border-left: 3px solid var(--accent-yellow); }
.deadline-ok { border-left: 3px solid var(--accent-green); }

/* ─── CHAT ───────────────────────────────────────── */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 8rem);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
    background: rgba(74, 158, 255, 0.1);
    border-color: rgba(74, 158, 255, 0.2);
}

.chat-message .agent-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.chat-message .agent-name.orchestrator { color: var(--agent-orchestrator); }
.chat-message .agent-name.researcher { color: var(--agent-researcher); }
.chat-message .agent-name.strategist { color: var(--agent-strategist); }
.chat-message .agent-name.advocate { color: var(--agent-advocate); }
.chat-message .agent-name.psychologist { color: var(--agent-psychologist); }
.chat-message .agent-name.paralegal { color: var(--agent-paralegal); }

.chat-message .content {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 3rem;
    max-height: 8rem;
}

.chat-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ─── WAR ROOM ───────────────────────────────────── */

.wargame-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: calc(100vh - 10rem);
}

.wargame-input, .wargame-output {
    display: flex;
    flex-direction: column;
}

.wargame-input textarea {
    flex: 1;
    resize: none;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.wargame-output {
    overflow-y: auto;
}

.wargame-section {
    margin-bottom: 1.5rem;
}

.wargame-section h4 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.wargame-section.predicted h4 { color: var(--accent-red); }
.wargame-section.counter h4 { color: var(--accent-green); }
.wargame-section.improved h4 { color: var(--accent-blue); }
.wargame-section.persuasion h4 { color: var(--accent-purple); }

/* ─── FILE UPLOAD ────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.05);
}

.upload-zone p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

/* ─── LOADING / THINKING ─────────────────────────── */

.thinking {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
}

.thinking-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: dot-bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ─── UTILITIES ──────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.hidden { display: none; }

/* ─── TEXT-TO-SPEECH CONTROLS ────────────────────── */

.tts-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

#tts-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

#tts-toggle:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

#tts-toggle.tts-active {
    background: rgba(52, 211, 153, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.tts-icon { font-size: 1rem; }

.tts-speed-control {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tts-speed-control input[type="range"] {
    width: 70px;
    height: 4px;
    padding: 0;
    accent-color: var(--accent-blue);
}

.tts-speak-btn {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.6rem !important;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.tts-speak-btn:hover { opacity: 1; }

.chat-message .tts-speak-btn {
    margin-top: 0.5rem;
    display: inline-block;
}

/* ─── DOCUMENT VAULT ────────────────────────────── */

.doc-open-link {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.15s;
}

.doc-open-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ─── WAR-GAME HISTORY ─────────────────────────── */

.wargame-section .card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* ─── HTMX TRANSITIONS ──────────────────────────── */

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-settling { opacity: 0.8; }
