/* ============================================================
   CuraEngine QMS Regulatory Console – Stylesheet
   Design: Dark professional, medical-grade UI
   ============================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-surface: #1c2030;
    --bg-elevated: #242838;
    --border: #2a2f42;
    --border-light: #353a50;
    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b4;
    --text-muted: #6b7280;
    --accent: #0a7ea4;
    --accent-hover: #0c94c0;
    --accent-light: rgba(10, 126, 164, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --info-bg: rgba(10, 126, 164, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --transition: 150ms ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* { 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;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0d1220 50%, #0a1628 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 32px; }

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: white;
    font-size: 20px;
    font-weight: 700;
    border-radius: var(--radius);
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.logo-mark.small { width: 36px; height: 36px; font-size: 13px; }

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.form-group textarea { resize: vertical; font-family: var(--font-mono); font-size: 13px; }

.error-msg {
    background: var(--error-bg);
    color: var(--error);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.login-footer p { color: var(--text-muted); font-size: 11px; }
.login-footer .version { margin-top: 4px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-danger { background: var(--error); color: white; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }

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

/* ============================================================
   App Layout
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 { font-size: 15px; font-weight: 700; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); }

.nav-menu { list-style: none; padding: 8px; flex: 1; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover { background: var(--bg-surface); color: var(--text-primary); }
.nav-link.active { background: var(--accent-light); color: var(--accent); }

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

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info { display: flex; align-items: center; gap: 8px; font-size: 12px; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.view-header h1 { font-size: 22px; font-weight: 700; }
.view-subtitle { color: var(--text-secondary); font-size: 13px; width: 100%; }
.view-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* ============================================================
   Cards & Stats
   ============================================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

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

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.accent { border-left: 3px solid var(--accent); }
.stat-card.success { border-left: 3px solid var(--success); }
.stat-card.warning { border-left: 3px solid var(--warning); }
.stat-card.error { border-left: 3px solid var(--error); }

/* ============================================================
   Tables
   ============================================================ */
.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

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

.data-table .hash {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   Badges & Status
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-draft { background: var(--info-bg); color: var(--accent); }
.badge-review { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-archived { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

.badge-role { background: var(--accent-light); color: var(--accent); }

/* ============================================================
   Forms
   ============================================================ */
.form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

.select-sm {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font);
    outline: none;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] { margin-top: 2px; }

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

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* ============================================================
   Document Detail
   ============================================================ */
.doc-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.doc-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-meta-item .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-meta-item .value { font-size: 13px; font-weight: 500; }

.doc-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 300px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    max-height: 60vh;
}

/* ============================================================
   Products Grid
   ============================================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--transition);
}

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

.product-card h3 { font-size: 16px; margin-bottom: 8px; }
.product-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

.product-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   Export
   ============================================================ */
.export-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.export-card h3 { font-size: 16px; margin-bottom: 4px; }
.export-card p { font-size: 13px; color: var(--text-secondary); }

/* ============================================================
   Integrity
   ============================================================ */
.integrity-result {
    padding: 20px;
    border-radius: var(--radius);
    margin-top: 16px;
}

.integrity-valid {
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.integrity-broken {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================================
   Activity Feed
   ============================================================ */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text { font-size: 13px; color: var(--text-secondary); }
.activity-text strong { color: var(--text-primary); }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}

/* ============================================================
   Utilities
   ============================================================ */
.mt-4 { margin-top: 16px; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .view-actions { flex-wrap: wrap; }
}
