/* ═══════════════════════════════════════════
   Průvodky – Nemocnice Pelhřimov
   ═══════════════════════════════════════════ */

:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-hover: #f5f5f4;
    --border: #e7e5e4;
    --border-focus: #0c4a6e;
    --text: #1c1917;
    --text-muted: #78716c;
    --primary: #0c4a6e;
    --primary-light: #e0f2fe;
    --primary-hover: #0e5a85;
    --accent: #b45309;
    --accent-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

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

.brand-logo {
    flex-shrink: 0;
    border-radius: 9px;
    display: block;
}

.brand-text {
    min-width: 0;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

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

.sidebar-manuals {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.manuals-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.manual-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text);
    text-decoration: none;
    padding: 5px 6px;
    border-radius: 6px;
    transition: all 0.12s;
}

.manual-link:hover {
    background: var(--surface-hover);
    color: var(--primary);
}

.manual-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.12s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface-hover);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.badge-count {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
}

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

.user-avatar, .table-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-dept { font-size: 11px; color: var(--text-muted); }
.user-info { min-width: 0; overflow: hidden; }

.sidebar-logout {
    display: block;
    padding: 8px 16px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.12s;
}
.sidebar-logout:hover { color: var(--danger); }

.main-content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
    min-width: 0;
}

/* ─── Typography ─── */
.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
}

.page-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    margin-top: -16px;
}

/* ─── Cards ─── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow-x: auto;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.card-header-title {
    font-weight: 600;
    font-size: 15px;
}

/* ─── Stats ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

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

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

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Pruvodka list ─── */
.pruvodka-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pruvodka-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s;
    box-shadow: var(--shadow);
}

.pruvodka-row:hover { border-color: var(--primary); }

.inbox-row { border-left: 4px solid var(--accent); }

.inbox-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.inbox-waiting {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin-right: 12px;
    flex-shrink: 0;
}
.inbox-days {
    font-size: 13px;
    font-weight: 600;
    color: #57534e;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f5f5f4;
}
.inbox-days--warn { color: #92400e; background: #fef3c7; }
.inbox-days--urgent { color: #991b1b; background: #fee2e2; }
.inbox-since { font-size: 11px; color: var(--text-muted); }

.pr-main { flex: 1; min-width: 0; }
.pr-subject { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.pr-typ-smlouvy { font-weight: 400; color: #78716c; font-size: 13px; }
.pr-partner { font-size: 13px; color: var(--text-muted); }
.pr-date { font-size: 12px; color: var(--text-muted); width: 80px; text-align: right; flex-shrink: 0; }

/* ─── Status badges ─── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.status-draft { color: #6b7280; background: #f3f4f6; }
.status-pending { color: #d97706; background: #fef3c7; }
.status-approved, .status-completed { color: #059669; background: #d1fae5; }
.status-returned { color: #dc2626; background: #fee2e2; }
.status-cancelled { color: #57534e; background: #e7e5e4; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
    letter-spacing: 0.01em;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-icon { display: inline-flex; padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer; transition: background 0.12s; }
.btn-icon:hover { background: var(--surface-hover); }

/* ─── Forms ─── */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--border-focus); }
.form-input-disabled { background: var(--surface-hover); color: var(--text-muted); }

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

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

.required { color: var(--danger); }

.inline-form-row { display: flex; gap: 8px; align-items: flex-start; }
.inline-form-row .form-input { flex: 1; }

select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 60px; }

/* ─── Detail ─── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
    transition: color 0.12s;
}
.back-link:hover { color: var(--primary); }

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-header > div:first-child { flex: 1; }
.detail-header .page-title { margin-bottom: 0; }

.pruvodka-number {
    font-size: 13px;
    font-weight: 600;
    font-family: monospace;
    color: #a8a29e;
    margin-bottom: 2px;
}

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

.detail-content {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.field-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.field-value { font-size: 14px; font-weight: 500; }

/* ─── Workflow progress ─── */
.workflow-progress { }

.wf-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.wf-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--border);
    color: var(--text-muted);
}

.wf-circle.wf-done { background: var(--success); color: #fff; }
.wf-circle.wf-returned { background: var(--danger); color: #fff; }
.wf-circle.wf-current { background: var(--accent); color: #fff; }

.wf-detail { padding-top: 4px; }
.wf-approver { margin-bottom: 2px; }
.wf-approver-name { font-weight: 500; font-size: 14px; }
.wf-status-ok { color: var(--success); font-size: 12px; margin-left: 8px; }
.wf-status-ret { color: var(--danger); font-size: 12px; margin-left: 8px; }
.wf-status-wait { color: var(--accent); font-size: 12px; margin-left: 8px; }
.wf-parallel-tag { font-size: 11px; color: var(--accent); font-weight: 600; }

/* ─── Action cards ─── */
.action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.action-text { flex: 1; font-size: 14px; }
.action-draft { border-left: 4px solid var(--primary); }
.action-approve { border-left: 4px solid var(--accent); }
.action-returned { border-left: 4px solid var(--danger); }
.action-completed { border-left: 4px solid var(--success); }
.action-cancelled { border-left: 4px solid #78716c; }
.action-withdraw { border-left: 4px solid #d97706; }

.pdf-generated-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 500;
    color: #059669;
}

.wf-waiting-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #92400e;
    font-size: 14px;
    line-height: 1.4;
}
.wf-waiting-banner svg { flex-shrink: 0; }

.cancel-block {
    width: 100%;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}
.cancel-block-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.cancel-block textarea {
    width: 100%;
    margin-bottom: 8px;
    resize: vertical;
}

.approval-form { width: 100%; }
.approval-buttons { display: flex; gap: 12px; margin-top: 8px; }

/* ─── Attachments / Notes ─── */
.attachment-list, .notes-list { margin-bottom: 16px; }

.attachment-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.att-name { flex: 1; font-weight: 500; }
.att-meta { color: var(--text-muted); font-size: 12px; }

.attachment-row--inactive {
    opacity: 0.55;
}
.attachment-row--inactive .att-name {
    text-decoration: line-through;
    font-weight: 400;
}
.att-inactive-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.note-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.note-text { font-size: 14px; margin-bottom: 4px; }
.note-meta { font-size: 11px; color: var(--text-muted); }

/* ─── Email log ─── */
.email-log { max-height: 200px; overflow-y: auto; }

.email-row {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.email-to { color: var(--text); font-weight: 500; flex-shrink: 0; }
.email-subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-time { flex-shrink: 0; }

/* ─── Tags / chips ─── */
.tag-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
}

/* ─── Checkbox grid ─── */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}
.checkbox-item small { color: var(--text-muted); }

/* ─── Tables ─── */
.data-table, .steps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th, .steps-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td, .steps-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.mode-tag {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 8px;
}
.mode-serial { background: #e0f2fe; color: #0c4a6e; }
.mode-parallel { background: #fef3c7; color: #b45309; }

.add-step-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.add-step-form .form-input { width: auto; flex: 1; }

/* ─── Flash messages ─── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.flash-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.flash-info { background: var(--primary-light); color: var(--primary); border: 1px solid #bae6fd; }

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 48px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.empty-state p { margin: 12px 0 20px; color: var(--text-muted); font-size: 15px; }

/* ─── Login page ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.login-brand {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-sub {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-section-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.login-form .form-group { margin-bottom: 16px; }

/* ─── ARES ─── */
.btn-ares {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.12s;
    font-family: var(--font);
}
.btn-ares:hover { background: var(--primary-light); }

.ares-result {
    font-size: 12px;
    margin-top: 4px;
    min-height: 18px;
}

.ares-result.found { color: var(--success); }
.ares-result.error { color: var(--danger); }
.ares-result.loading { color: var(--text-muted); font-style: italic; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-nav { display: flex; flex-wrap: wrap; padding: 8px; }
    .nav-item { font-size: 13px; padding: 8px 10px; }
    .sidebar-user { display: none; }
    .sidebar-logout { display: none; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-row-4 { grid-template-columns: 1fr 1fr; }
}
