/* HL7 Generator 2000 - Dashboard Styles */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #1e2538;
    --bg-hover: #252d42;
    --text-primary: #e4e8f0;
    --text-secondary: #8b95a5;
    --text-muted: #5a6578;
    --accent: #00d4aa;
    --accent-dim: #00a885;
    --danger: #ff4757;
    --warning: #ffa502;
    --success: #2ed573;
    --info: #1e90ff;
    --border: #2a3245;
    --sidebar-width: 220px;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 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);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

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

.sidebar-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.accent {
    color: var(--accent);
}

.nav-links {
    list-style: none;
    padding: 10px 0;
    flex: 1;
}

.nav-links a {
    display: block;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

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

.nav-links a.active {
    background: var(--bg-hover);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.logout-link {
    display: block;
    margin-top: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
}

.logout-link:hover {
    color: var(--danger);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.running    { background: rgba(46, 213, 115, 0.2); color: var(--success); }
.status-badge.stopped    { background: rgba(255, 71, 87, 0.2); color: var(--danger); }
.status-badge.paused     { background: rgba(255, 165, 2, 0.2); color: var(--warning); }
.status-badge.active     { background: rgba(46, 213, 115, 0.2); color: var(--success); }
.status-badge.idle       { background: rgba(100, 116, 139, 0.2); color: var(--text-secondary); }
.status-badge.discharged { background: rgba(255, 165, 2, 0.2); color: var(--warning); }
.status-badge.retired    { background: rgba(255, 71, 87, 0.15); color: var(--text-muted); }

/* Main Content */
.content {
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    flex: 1;
    min-width: 0;
}

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

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

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    color: white;
}

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-warning { background: var(--warning); color: #1a1f2e; }
.btn-primary { background: var(--info); }
.btn-secondary { background: var(--text-muted); }

.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.controls { display: flex; gap: 8px; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Rate Control */
.rate-control {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.rate-control label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#rate-display {
    color: var(--accent);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

/* Section */
.section {
    margin-bottom: 24px;
}

.section h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

/* Message Feed */
.message-feed {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.feed-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
}

.feed-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    display: flex;
    gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.feed-item:hover { background: var(--bg-hover); }
.feed-item:last-child { border-bottom: none; }

.feed-time { color: var(--text-muted); white-space: nowrap; }
.feed-type {
    color: var(--accent);
    font-weight: 600;
    min-width: 80px;
}
.feed-patient { color: var(--text-secondary); }

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr { cursor: pointer; }

/* Search Bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

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

.search-bar input {
    flex: 1;
}

.search-bar input:focus,
.search-bar select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

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

.workflow-card h4 {
    margin-bottom: 8px;
    color: var(--accent);
}

.workflow-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.workflow-card .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Form Cards */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.form-card h3 {
    margin-bottom: 16px;
    font-size: 1rem;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-row input,
.form-row select {
    display: block;
    margin-top: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.hl7-content {
    padding: 16px 20px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    flex: 1;
}

/* Chart */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chart-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.chart-bar-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 60px;
}

.chart-bar-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Settings */
.settings-container {
    max-width: 700px;
}

/* Pool Stats */
.pool-stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Patient Timeline */
.timeline {
    position: relative;
    padding: 16px 0;
}

.timeline-loading,
.timeline-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.timeline-event {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-left: 36px;
    margin-bottom: 0;
    cursor: pointer;
}

.timeline-line {
    position: absolute;
    left: 13px;
    top: 12px;
    bottom: -12px;
    width: 2px;
    background: var(--border);
}

.timeline-line-last {
    display: none;
}

.timeline-node {
    position: absolute;
    left: 6px;
    top: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--bg-primary);
    z-index: 1;
}

.timeline-node-ok {
    border-color: var(--accent);
}

.timeline-node-error {
    border-color: var(--danger);
    background: rgba(255, 71, 87, 0.2);
}

.timeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    flex: 1;
    transition: background 0.15s;
}

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

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.timeline-type {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

.timeline-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.timeline-warn {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h1, .nav-links a span { display: none; }
    .content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
