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

:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2733;
    --bg-card: #1e2d3d;
    --bg-input: #253545;
    --bg-hover: #2a3a4a;
    --border: #2d3f50;
    --text-primary: #e8edf2;
    --text-secondary: #8899aa;
    --text-muted: #667788;
    --accent-blue: #4a9eff;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-orange: #fb923c;
    --accent-yellow: #fbbf24;
    --accent-purple: #a78bfa;
    --accent-cyan: #22d3ee;
    --sidebar-width: 220px;
}

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

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    text-align: center;
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.login-box input:focus {
    border-color: var(--accent-blue);
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.login-box button:hover {
    opacity: 0.9;
}

.error-text {
    color: var(--accent-red);
    font-size: 13px;
    margin-top: 12px;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
    display: flex;
    height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--text-primary);
    background: var(--accent-blue);
    border-radius: 0;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-bottom {
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-admin-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 20px 4px;
    letter-spacing: 0.5px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.user-info span:first-child {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-label {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.logout-btn:hover {
    color: var(--text-primary);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.view h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.view-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dash-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}

.dash-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-green);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.overdue-list {
    max-height: 300px;
    overflow-y: auto;
}

.overdue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.overdue-item:last-child {
    border-bottom: none;
}

.overdue-name {
    font-weight: 600;
}

.overdue-date {
    color: var(--accent-red);
    font-size: 12px;
}

.pipeline-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.pipeline-stat {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px 24px;
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.pipeline-stat .stat-number {
    font-size: 28px;
    font-weight: 700;
}

.pipeline-stat .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

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

/* ============================================================
   TABLES
   ============================================================ */
.team-table {
    width: 100%;
    border-collapse: collapse;
}

.team-table th {
    text-align: left;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.team-table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.team-table tbody tr:hover {
    background: var(--bg-hover);
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.dot-orange { background: var(--accent-orange); }
.dot-blue { background: var(--accent-blue); }
.dot-yellow { background: var(--accent-yellow); }
.dot-purple { background: var(--accent-purple); }
.dot-cyan { background: var(--accent-cyan); }
.dot-green { background: var(--accent-green); }
.dot-red { background: var(--accent-red); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-blue);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    padding: 10px 20px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

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

.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

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

.btn-green {
    padding: 10px 20px;
    background: var(--accent-green);
    color: #0f1923;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

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

.btn-red {
    padding: 8px 16px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

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

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 8px;
}

/* ============================================================
   ARTICLE GENERATOR
   ============================================================ */
.generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.charge-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.charge-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.charge-input:focus {
    border-color: var(--accent-blue);
}

.charge-remove {
    background: none;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
}

.autofill-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.autofill-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.autofill-item:last-child {
    border-bottom: none;
}

.autofill-freq {
    font-size: 11px;
    color: var(--text-muted);
}

.autofill-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.autofill-status.approved {
    background: rgba(52, 211, 153, 0.2);
    color: var(--accent-green);
}

.autofill-status.pending {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
}

.article-preview-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    min-height: 300px;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.preview-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

#article-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* ============================================================
   KANBAN BOARD
   ============================================================ */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.board-header h1 {
    margin-bottom: 0;
}

.board-filters select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
}

.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 20px;
    height: calc(100vh - 140px);
}

.kanban-column {
    min-width: 240px;
    max-width: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kanban-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px 10px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
}

.kanban-count {
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 8px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: transform 0.1s;
}

.kanban-card:hover {
    border-color: var(--accent-blue);
}

.kanban-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.card-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.card-county {
    font-size: 12px;
    color: var(--text-secondary);
}

.card-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.card-overdue {
    border-left: 3px solid var(--accent-red);
}

/* ============================================================
   CHARGE REVIEW
   ============================================================ */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.review-header h1 {
    margin-bottom: 0;
}

.review-queue {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.review-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}

.review-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.review-charge-name {
    font-size: 16px;
    font-weight: 700;
}

.review-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.review-confidence {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}

.confidence-HIGH {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}

.confidence-MEDIUM {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-yellow);
}

.confidence-LOW {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-red);
}

.review-description {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.review-description h4 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.review-description p {
    margin-bottom: 8px;
}

.review-description p:last-child {
    margin-bottom: 0;
}

.review-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-large {
    width: 640px;
}

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

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================================
   DECLINE CHAT
   ============================================================ */
.decline-current {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

.chat-messages {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.chat-message {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user {
    background: var(--accent-blue);
    color: white;
    margin-left: 40px;
}

.chat-message.assistant {
    background: var(--bg-card);
    margin-right: 40px;
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-row textarea {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
}

.chat-input-row textarea:focus {
    border-color: var(--accent-blue);
}

/* ============================================================
   REPORTS
   ============================================================ */
.report-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.report-filters select,
.report-filters input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.report-results {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
}

.report-total {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
