/* =============================================================================
   LinkedIn Agent Dashboard - Activity Monitor Dark Theme
   Inspired by Apple's Activity Monitor / macOS system UI
   ============================================================================= */

:root {
    --bg-primary: #1e1e1e;
    --bg-panel: #252525;
    --bg-card: #2d2d2d;
    --bg-hover: #333333;
    --bg-input: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;
    --separator: #3a3a3c;
    --approved: #30d158;
    --pending: #ffd60a;
    --rejected: #ff453a;
    --posted: #0a84ff;
    --failed: #ff6b6b;
    --accent: #0a84ff;
    --brand-dark: #474972;
    --brand-gold: #DCB95B;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ===== Layout Shell ===== */

.shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== Header Bar ===== */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--separator);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--approved);
    animation: pulse 2s infinite;
}

.header-dot.warning { background: var(--pending); }
.header-dot.error { background: var(--rejected); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.header-status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Tab Navigation (Segmented Control) ===== */

.tab-nav {
    display: flex;
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 16px;
    border: 1px solid var(--separator);
}

.tab-nav a {
    flex: 1;
    text-align: center;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

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

.tab-nav a.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== Content Area ===== */

.content {
    min-height: 60vh;
}

/* ===== Footer Bar ===== */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    margin-top: 16px;
    border: 1px solid var(--separator);
    font-size: 12px;
    color: var(--text-secondary);
}

.footer-stats {
    display: flex;
    gap: 20px;
}

.footer-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-stat .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot-green { background: var(--approved); }
.dot-yellow { background: var(--pending); }
.dot-red { background: var(--rejected); }
.dot-blue { background: var(--posted); }

/* ===== Cards ===== */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--separator);
    padding: 16px;
    margin-bottom: 12px;
}

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

.card-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* ===== Status Badges ===== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-pending { background: rgba(255, 214, 10, 0.15); color: var(--pending); }
.badge-approved { background: rgba(48, 209, 88, 0.15); color: var(--approved); }
.badge-rejected { background: rgba(255, 69, 58, 0.15); color: var(--rejected); }
.badge-posted { background: rgba(10, 132, 255, 0.15); color: var(--posted); }
.badge-failed { background: rgba(255, 107, 107, 0.15); color: var(--failed); }
.badge-edited { background: rgba(175, 130, 255, 0.15); color: #af82ff; }

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-pending::before { background: var(--pending); }
.badge-approved::before { background: var(--approved); }
.badge-rejected::before { background: var(--rejected); }
.badge-posted::before { background: var(--posted); }
.badge-failed::before { background: var(--failed); }
.badge-edited::before { background: #af82ff; }

/* ===== Approval Pressure Bar ===== */

.pressure-bar {
    height: 4px;
    background: var(--separator);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

.pressure-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease, background 0.5s ease;
}

.pressure-low { background: var(--approved); }
.pressure-medium { background: var(--pending); }
.pressure-high { background: var(--rejected); }

/* ===== Approval Post Panel ===== */

.approval-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--separator);
    margin-bottom: 16px;
    overflow: hidden;
}

.approval-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--separator);
}

.approval-panel-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.approval-panel-body {
    display: flex;
    gap: 16px;
    padding: 16px;
}

.approval-text {
    flex: 1;
    max-height: 300px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
    padding-right: 8px;
}

.approval-text::-webkit-scrollbar {
    width: 4px;
}

.approval-text::-webkit-scrollbar-thumb {
    background: var(--separator);
    border-radius: 2px;
}

.approval-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.approval-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.approval-image-placeholder {
    color: var(--text-tertiary);
    font-size: 12px;
}

.approval-panel-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--separator);
}

/* ===== Buttons ===== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 16px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font);
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }

.btn-approve { background: rgba(48, 209, 88, 0.2); color: var(--approved); }
.btn-reject { background: rgba(255, 69, 58, 0.2); color: var(--rejected); }
.btn-edit { background: rgba(175, 130, 255, 0.2); color: #af82ff; }
.btn-regen { background: rgba(10, 132, 255, 0.2); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-default { background: var(--bg-hover); color: var(--text-primary); }

.btn-approve:hover { background: rgba(48, 209, 88, 0.3); }
.btn-reject:hover { background: rgba(255, 69, 58, 0.3); }

/* ===== Table ===== */

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

.table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--separator);
}

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

.table tr:last-child td { border-bottom: none; }

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

/* ===== Progress Bar ===== */

.progress {
    height: 6px;
    background: var(--separator);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ===== Metric Blocks ===== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metric {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--separator);
    padding: 14px 16px;
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ===== Edit Modal ===== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-panel);
    border-radius: var(--radius);
    border: 1px solid var(--separator);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

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

.modal-body { padding: 16px; }

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

textarea.edit-area {
    width: 100%;
    min-height: 200px;
    background: var(--bg-input);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.6;
    padding: 12px;
    resize: vertical;
}

textarea.edit-area:focus {
    outline: none;
    border-color: var(--accent);
}

.char-count {
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: right;
    margin-top: 4px;
}

.char-count.over { color: var(--rejected); }

/* ===== System Tab ===== */

.log-output {
    background: var(--bg-input);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* ===== Token Bar ===== */

.token-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.token-bar-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 100px;
}

.token-bar-progress {
    flex: 1;
    height: 8px;
    background: var(--separator);
    border-radius: 4px;
    overflow: hidden;
}

.token-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.token-bar-value {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
}

/* ===== Empty State ===== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
}

/* ===== Toast Notifications ===== */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    z-index: 200;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { border-left: 3px solid var(--approved); }
.toast-error { border-left: 3px solid var(--rejected); }

/* ===== HTMX Loading ===== */

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

/* ===== Collapsible History Panels ===== */

.history-panel .history-body {
    display: none;
    border-top: 1px solid var(--separator);
}

.history-panel.expanded .history-body {
    display: flex;
}

.history-panel .expand-arrow {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}

.history-panel.expanded .expand-arrow {
    transform: rotate(180deg);
}

.history-panel .approval-panel-header:hover {
    background: var(--bg-hover);
}

/* ===== Merge Toolbar ===== */

.merge-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(10, 132, 255, 0.1);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    margin-bottom: 12px;
    position: sticky;
    top: 8px;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.merge-toolbar-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.merge-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.merge-input {
    background: var(--bg-input);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    padding: 6px 10px;
    width: 240px;
}

.merge-input:focus {
    outline: none;
    border-color: var(--accent);
}

.merge-input::placeholder {
    color: var(--text-tertiary);
}

/* ===== Merge Checkbox ===== */

.merge-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.merge-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.merge-checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--separator);
    border-radius: 4px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.merge-checkbox input:checked + .merge-checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.merge-checkbox input:checked + .merge-checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.merge-checkbox:hover .merge-checkmark {
    border-color: var(--accent);
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
    .shell { padding: 8px; }
    .approval-panel-body { flex-direction: column; }
    .approval-image { width: 100%; height: 200px; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-stats { gap: 12px; flex-wrap: wrap; }
    .tab-nav a { padding: 8px 8px; font-size: 12px; }
}

/* =============================================================================
   Chat Section - LLM-basierte Post-Bearbeitung
   ============================================================================= */

.chat-section {
    border-top: 1px solid var(--separator);
    padding: 12px 16px;
    background: var(--bg-primary);
}

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

.chat-messages:empty {
    display: none;
}

.chat-messages:empty + .chat-input-row {
    margin-top: 0;
}

.chat-msg {
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    animation: chatFadeIn 0.2s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
    background: rgba(10, 132, 255, 0.15);
    color: var(--accent);
    margin-left: 40px;
    text-align: right;
}

.chat-msg-system {
    background: var(--bg-card);
    color: var(--text-primary);
    margin-right: 40px;
}

.chat-msg-error {
    background: rgba(255, 69, 58, 0.15);
    color: var(--rejected);
}

.chat-loading {
    color: var(--text-secondary);
    font-style: italic;
}

.chat-loading::after {
    content: '';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

.chat-refined-preview {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.chat-refined-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.chat-refined-actions {
    display: flex;
    gap: 6px;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--separator);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 16px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}

.chat-send {
    border-radius: 20px !important;
    padding: 8px 16px !important;
}

.btn-sm {
    padding: 4px 10px !important;
    font-size: 11px !important;
}

/* =============================================================================
   Regenerate Toolbar
   ============================================================================= */

.regen-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.regen-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.regen-actions {
    display: flex;
    gap: 8px;
}

.btn-regen {
    background: rgba(10, 132, 255, 0.2);
    color: var(--accent);
}

.btn-regen:hover {
    background: rgba(10, 132, 255, 0.3);
}

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