/* app/static/css/style.css | v2.3.3 */
:root {
    --fti-orange: #ff6600;
    --fti-orange-dark: #df5900;
    --fti-border: rgba(0, 0, 0, 0.12);
}

html, body { min-height: 100%; }
body { background: var(--bs-tertiary-bg); }
.btn-primary {
    --bs-btn-bg: var(--fti-orange);
    --bs-btn-border-color: var(--fti-orange);
    --bs-btn-hover-bg: var(--fti-orange-dark);
    --bs-btn-hover-border-color: var(--fti-orange-dark);
    --bs-btn-active-bg: var(--fti-orange-dark);
    --bs-btn-active-border-color: var(--fti-orange-dark);
}
.text-primary { color: var(--fti-orange) !important; }
.navbar-logo { width: 72px; height: 48px; object-fit: contain; object-position: left center; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.form-signin { width: 100%; max-width: 420px; }
.login-card { border-top: 4px solid var(--fti-orange) !important; }
.login-logo { width: min(190px, 52vw); height: 96px; object-fit: contain; object-position: center; }
.login-brand-name { font-size: 2rem; font-weight: 800; color: var(--bs-body-color); letter-spacing: -.03em; }
.login-theme-toggle { z-index: 1030; }
.app-page, .admin-page { min-height: 100vh; }
.min-w-0 { min-width: 0; }
.gap-x-3 { column-gap: 1rem; }
.gap-y-1 { row-gap: .25rem; }

.user-department-area { white-space: nowrap; min-width: 0; }
.user-department-label { font-size: .76rem; color: var(--bs-secondary-color); letter-spacing: .02em; }
.user-department-name { font-size: 1.22rem; font-weight: 750; color: var(--fti-orange); overflow: hidden; text-overflow: ellipsis; }
.department-header-icon { font-size: 1.45rem; line-height: 1; }

.dashboard-columns { align-items: stretch; }
.request-column-card { min-height: calc(100vh - 86px); }
.request-column-header { padding: .6rem .7rem; }
.request-filter-bar { display: grid; grid-template-columns: minmax(115px, 1fr) repeat(4, minmax(82px, auto)) 34px; gap: .35rem; align-items: center; }
.request-search-control { min-width: 0; }
.request-filter-select { min-width: 0; max-width: 135px; }
.request-view-toggle { width: 34px; padding-left: .35rem; padding-right: .35rem; }
.request-list { max-height: calc(100vh - 180px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.request-card {
    --priority-color: #dc3545;
    border: 1px solid var(--bs-border-color);
    border-left: 6px solid var(--priority-color) !important;
    background: var(--bs-body-bg);
    transition: box-shadow 140ms ease, transform 140ms ease, background-color 140ms ease;
    overflow: visible;
    position: relative;
}
.request-card:hover, .request-card:focus-within { box-shadow: 0 .3rem .85rem rgba(0, 0, 0, .09); z-index: 25; }
.request-card > .card-body { overflow: visible; }
.request-card.compact { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .75rem; margin-bottom: .5rem; border-radius: var(--bs-border-radius); }
.request-content-preview { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.request-actions .btn { white-space: nowrap; }
.party-icon { font-size: 1.05em; }
.priority-badge { background: var(--priority-color) !important; color: #fff !important; }
.priority-level-0 { border-left-color: var(--bs-border-color) !important; }
.priority-level-1 { border-color: color-mix(in srgb, var(--priority-color) 70%, var(--bs-border-color)) !important; border-left-color: var(--priority-color) !important; }
.priority-level-2 { background: color-mix(in srgb, var(--priority-color) 7%, var(--bs-body-bg)) !important; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--priority-color) 24%, transparent); }
.priority-level-3 { background: color-mix(in srgb, var(--priority-color) 14%, var(--bs-body-bg)) !important; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--priority-color) 36%, transparent); }
.priority-level-4 { background: color-mix(in srgb, var(--priority-color) 23%, var(--bs-body-bg)) !important; box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--priority-color) 50%, transparent), 0 0 1rem color-mix(in srgb, var(--priority-color) 22%, transparent); }
.priority-pulse { animation: priority-pulse 1.35s ease-in-out infinite; }
@keyframes priority-pulse {
    0%, 100% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--priority-color) 38%, transparent), 0 0 0 0 color-mix(in srgb, var(--priority-color) 30%, transparent); }
    50% { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--priority-color) 64%, transparent), 0 0 0 .42rem color-mix(in srgb, var(--priority-color) 0%, transparent); }
}
.unread-highlight { outline: 2px solid rgba(255, 102, 0, .42); }
.status-postponed { border-bottom: 2px solid var(--bs-warning) !important; }
.status-completed { border-bottom: 2px solid var(--bs-success) !important; }
.status-approved { border-color: var(--bs-success) !important; opacity: .92; }
.status-cancelled { opacity: .82; filter: saturate(.65); }
.final-archive-note { font-size: .78rem; font-weight: 700; color: var(--bs-success); margin-bottom: .45rem; }
.empty-state { min-height: 160px; }

.chat-modal-body { min-height: 440px; max-height: 75vh; }
.chat-messages { height: 430px; overflow-y: auto; overscroll-behavior: contain; padding: .35rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-tertiary-bg); }
.chat-row { display: flex; margin-bottom: .6rem; }
.chat-row.mine { justify-content: flex-end; }
.chat-row.theirs { justify-content: flex-start; }
.chat-bubble { max-width: 82%; padding: .65rem .8rem; border-radius: .85rem; border: 1px solid var(--bs-border-color); word-break: break-word; background: var(--bs-body-bg); }
.chat-bubble.mine { background: color-mix(in srgb, var(--fti-orange) 12%, var(--bs-body-bg)); border-color: color-mix(in srgb, var(--fti-orange) 30%, var(--bs-border-color)); }
.attachment-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.attachment-item { display: inline-flex; align-items: center; gap: .45rem; max-width: 100%; padding: .45rem .6rem; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: var(--bs-body-bg); color: var(--bs-body-color); text-decoration: none; font-size: .82rem; }
.attachment-item:hover { border-color: var(--fti-orange); color: var(--fti-orange); }
.attachment-item.image { flex-direction: column; align-items: flex-start; width: 170px; }
.attachment-item.image img { width: 100%; height: 105px; object-fit: cover; border-radius: .35rem; background: var(--bs-tertiary-bg); }
.attachment-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.timeline-list { list-style: none; padding-left: 0; margin-bottom: 0; }
.timeline-item { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--bs-border-color); margin-left: .4rem; }
.timeline-item::before { content: ''; position: absolute; width: .7rem; height: .7rem; left: -.42rem; top: .22rem; border-radius: 50%; background: var(--fti-orange); }
.timeline-item:last-child { border-left-color: transparent; }
.validation-hint:empty { display: none; }
.app-toast-container { z-index: 2000; }

.export-field-grid { max-height: 250px; overflow-y: auto; padding-right: .25rem; }
.export-field-grid .form-check { min-height: 1.7rem; }
.admin-danger-note { border-left: 4px solid var(--bs-danger); }

.admin-tabs { scrollbar-width: thin; }
.admin-tabs .nav-link { white-space: nowrap; }
.department-icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: .4rem; max-height: 230px; overflow-y: auto; padding: .5rem; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: var(--bs-tertiary-bg); }
.department-icon-option { appearance: none; border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); border-radius: .45rem; min-height: 42px; font-size: 1.4rem; cursor: pointer; transition: transform 100ms ease, border-color 100ms ease, box-shadow 100ms ease; }
.department-icon-option:hover { transform: translateY(-1px); border-color: var(--fti-orange); }
.department-icon-option.active { border: 2px solid var(--fti-orange); box-shadow: 0 0 0 .15rem rgba(255, 102, 0, .18); }
.department-icon-display { font-size: 1.4rem; }
.template-field-grid .card { background: var(--bs-tertiary-bg); }
.template-editor-row > td { padding: .75rem !important; background: color-mix(in srgb, var(--fti-orange) 4%, var(--bs-body-bg)); }
.template-editor-panel { border-color: color-mix(in srgb, var(--fti-orange) 45%, var(--bs-border-color)) !important; }
.template-editor-panel .card-header { background: color-mix(in srgb, var(--fti-orange) 8%, var(--bs-body-bg)); }
.priority-swatch { display: inline-block; width: .8rem; height: .8rem; background: var(--priority-color); border-radius: 50%; vertical-align: -.06rem; margin-right: .25rem; }
.admin-master-table { max-height: calc(100vh - 220px); }
.admin-master-table thead th { position: sticky; top: 0; z-index: 2; background: var(--bs-body-bg); }
.admin-title-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-wrap { min-height: 320px; height: 36vh; max-height: 430px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
code { color: var(--fti-orange); }

@media (prefers-reduced-motion: reduce) {
    .priority-pulse { animation: none; }
}

@media (max-width: 1199.98px) {
    .request-column-card { min-height: auto; }
    .request-list { max-height: none; overflow-y: visible; }
    .admin-master-table { max-height: none; }
}

@media (max-width: 767.98px) {
    body.app-page { font-size: .95rem; }
    .navbar-logo { width: 58px; height: 39px; }
    .app-brand-name { font-size: 1.05rem; }
    .app-header-actions { gap: .25rem !important; }
    .app-header-actions .btn { padding-left: .45rem; padding-right: .45rem; }
    .header-action-separator { width: .2rem; }
    .request-filter-bar { grid-template-columns: minmax(105px, 1fr) repeat(2, minmax(82px, auto)) 34px; }
    .request-filter-bar .request-filter-select:nth-of-type(3) { grid-column: span 1; }
    .request-filter-select { max-width: 118px; }
    .user-department-label { font-size: .65rem; }
    .user-department-name { font-size: 1rem; max-width: 34vw; }
    .department-header-icon { font-size: 1.1rem; }
    .app-header .btn-label { display: none; }
    .request-card.compact { align-items: flex-start; flex-direction: column; }
    .request-actions { width: 100%; display: flex; flex-wrap: wrap; gap: .25rem; }
    .request-actions .btn { flex: 1 1 auto; }
    .chat-modal-body { min-height: 0; max-height: none; }
    .chat-messages { height: calc(100vh - 190px); min-height: 260px; }
    .chat-bubble { max-width: 94%; }
    .attachment-item.image { width: calc(50% - .25rem); }
    .modal-footer { position: sticky; bottom: 0; background: var(--bs-body-bg); z-index: 2; }
    .stats-cards .h4 { font-size: 1.05rem; }
    .chart-wrap { min-height: 270px; height: 300px; }
}

@media (max-width: 480px) {
    .user-department-label { display: none; }
    .user-department-name { max-width: 42vw; }
    .request-card .card-body { padding: .75rem !important; }
    .request-card .small { font-size: .76rem; }
    .attachment-item.image { width: 100%; }
}


/* Záhlaví hlavní stránky: název oddělení je dominantní a přibližně vysoký jako logo. */
.app-brand-name { font-size: 1.25rem; font-weight: 800; color: var(--bs-body-color); letter-spacing: -.02em; }
.current-department { display: flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap; min-width: 0; line-height: 1; }
.current-department .dept-icon { font-size: 1.65rem; line-height: 1; flex: 0 0 auto; }
.current-department .dept-name { font-size: clamp(1.45rem, 2.25vw, 1.9rem); line-height: 1.05; color: var(--fti-orange); overflow: hidden; text-overflow: ellipsis; }
.header-action-separator { display: inline-block; width: .45rem; }

@media (max-width: 991.98px) {
    .request-column-card { min-height: auto; }
    .request-list { max-height: none; overflow-y: visible; }
}

@media (max-width: 767.98px) {
    .current-department { gap: .22rem; justify-content: flex-start; }
    .current-department .dept-name { font-size: 1.05rem; max-width: 25vw; }
    .current-department .dept-icon { font-size: 1.1rem; }
    .request-filter-bar { grid-template-columns: minmax(110px, 1fr) 100px 34px; }
    .request-search-control { grid-column: span 2; }
    .request-filter-select { max-width: none; }
    .request-filter-bar #inboxPriorityFilter, .request-filter-bar #outboxPriorityFilter,
    .request-filter-bar #inboxSortSelect, .request-filter-bar #outboxSortSelect { min-width: 0; }
    .login-logo { width: min(160px, 48vw); height: 82px; }
    .login-brand-name { font-size: 1.7rem; }
}

@media (max-width: 520px) {
    .navbar-brand { gap: .2rem !important; }
    .app-brand-name { font-size: .95rem; }
    .current-department .dept-name { max-width: 22vw; font-size: .95rem; }
    .current-department .dept-icon { display: none; }
    .app-header-actions .theme-toggle .ms-1 { margin-left: .15rem !important; }
    .request-filter-bar { grid-template-columns: 1fr 1fr 34px; }
    .request-search-control { grid-column: 1 / -1; }
    .login-brand { gap: .5rem !important; }
    .login-logo { width: min(145px, 46vw); height: 74px; }
    .login-brand-name { font-size: 1.55rem; }
}


/* v2.2.0 – konfigurovatelné panely a výběr pracovníka. */
.panel-mode-select { max-width: 260px; font-weight: 650; }
.current-worker-select { width: auto; max-width: 230px; min-width: 150px; font-size: .78rem; }
.template-launch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .65rem; }
.template-launch-card { border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease; }
.template-launch-card:hover { border-color: var(--fti-orange); box-shadow: 0 .25rem .8rem rgba(0,0,0,.08); transform: translateY(-1px); }

@media (max-width: 991.98px) {
    .current-worker-select { max-width: 180px; min-width: 120px; }
    .request-filter-bar { grid-template-columns: minmax(110px, 1fr) repeat(3, minmax(80px, auto)) 34px; }
    .request-search-control { grid-column: span 2; }
}

@media (max-width: 767.98px) {
    .current-worker-select { max-width: 130px; min-width: 95px; font-size: .7rem; }
    .panel-mode-select { max-width: 220px; }
    .request-filter-bar { grid-template-columns: 1fr 1fr 34px; }
    .request-search-control { grid-column: 1 / -1; }
    .template-launch-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .current-worker-select { max-width: 105px; min-width: 80px; padding-left: .35rem; padding-right: 1.4rem; }
    .panel-mode-select { max-width: calc(100vw - 105px); }
}


/* v2.3.0 – náhledy příloh, samostatné filtry, stroje a stabilní 100% desktop layout. */
[data-bs-theme="light"] {
    --bs-body-bg: #eef0f1;
    --bs-tertiary-bg: #d9dde0;
    --bs-secondary-bg: #e1e4e6;
    --bs-border-color: #b9c0c5;
}
[data-bs-theme="light"] .navbar-logo,
[data-bs-theme="light"] .login-logo {
    background: #596168;
    border-radius: .42rem;
    padding: .18rem .28rem;
    box-sizing: border-box;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.28));
}
.request-type-badge { background: var(--bs-secondary-bg) !important; color: var(--bs-body-color) !important; border: 1px solid var(--bs-border-color); }
.subtle-badge { background: var(--bs-secondary-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); }
.status-clarification { border-bottom: 2px solid var(--bs-info) !important; }
.request-filter-toggle.active { background: var(--bs-secondary-bg); border-color: var(--fti-orange); }
.request-filter-bar { grid-template-columns: minmax(130px, 1fr) repeat(4, minmax(92px, auto)); }
.request-card-row-1 .request-time { white-space: nowrap; }
.request-card-footer { min-width: 0; }
.request-action-button { min-width: 2.15rem; }

.chat-attention { animation: chat-attention 1s ease-in-out infinite; border-color: var(--fti-orange) !important; }
@keyframes chat-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,102,0,.15); background-color: transparent; }
    50% { box-shadow: 0 0 0 .28rem rgba(255,102,0,.16); background-color: rgba(255,102,0,.18); }
}

.request-attachment-hover, .machine-hover { position: relative; display: inline-flex; align-items: center; }
.attachment-paperclip, .machine-number { cursor: default; }
.attachment-hover-card, .machine-hover-card {
    display: none; position: absolute; left: 0; top: calc(100% + .35rem); z-index: 1085;
    min-width: 220px; max-width: 330px; max-height: 320px; overflow: auto;
    padding: .5rem; border: 1px solid var(--bs-border-color); border-radius: .55rem;
    background: var(--bs-body-bg); box-shadow: 0 .5rem 1.2rem rgba(0,0,0,.2);
}
.request-attachment-hover:hover .attachment-hover-card, .machine-hover:hover .machine-hover-card { display: grid; gap: .4rem; }
.attachment-hover-preview, .attachment-hover-document {
    border: 0; background: transparent; color: var(--bs-body-color); text-decoration: none; padding: .2rem;
    text-align: left; display: grid; gap: .25rem; width: 100%; font-size: .78rem;
}
.attachment-hover-preview:hover, .attachment-hover-document:hover { color: var(--fti-orange); }
.attachment-hover-preview img { width: 180px; max-width: 100%; height: 110px; object-fit: cover; border-radius: .35rem; }
.machine-hover-card { min-width: 230px; }
.machine-hover-card span { display: block; font-size: .76rem; margin-top: .2rem; }
.attachment-preview-body { min-height: 55vh; display: flex; align-items: center; justify-content: center; background: var(--bs-tertiary-bg); }
.attachment-preview-image { max-width: 100%; max-height: 72vh; object-fit: contain; }
.attachment-preview-frame { width: 100%; height: 72vh; border: 0; background: #fff; }
.attachment-item { cursor: pointer; }

.machine-editor-row > td { padding: .75rem !important; background: color-mix(in srgb, var(--fti-orange) 4%, var(--bs-body-bg)); }
.machine-detail-card { border-left: 4px solid var(--fti-orange); }
.machine-asset-thumb { width: 110px; height: 75px; object-fit: cover; border-radius: .35rem; }

@media (min-width: 992px) {
    html, body.app-page { height: 100%; overflow: hidden; }
    body.app-page { min-height: 100vh; display: flex; flex-direction: column; }
    .app-navbar { flex: 0 0 auto; }
    .app-main { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
    .dashboard-columns { flex: 1 1 auto; min-height: 0; overflow: hidden; }
    .dashboard-column { height: 100%; min-height: 0; }
    .request-column-card { height: 100%; min-height: 0; max-height: 100%; display: flex; flex-direction: column; }
    .request-column-header { flex: 0 0 auto; }
    .request-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overflow-x: visible; }
}

@media (max-width: 991.98px) {
    body.app-page { overflow: auto; }
    .request-list { max-height: 65vh; overflow-y: auto; }
    .request-filter-bar { grid-template-columns: 1fr 1fr; }
    .request-search-control { grid-column: 1 / -1; }
}

@media (max-width: 767.98px) {
    .request-card-row-1 { flex-direction: column; }
    .request-card-row-1 .request-time { width: 100%; text-align: left !important; }
    .request-card-footer { flex-direction: column; align-items: stretch !important; }
    .request-card-footer .request-actions { justify-content: flex-end !important; }
    .request-card.compact { flex-direction: row; align-items: center; }
    .request-card.compact .request-actions { width: auto; flex-wrap: nowrap; }
    .request-card.compact .request-actions .btn { flex: 0 0 auto; }
    .request-filter-bar { grid-template-columns: 1fr 1fr; }
    .panel-mode-select { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) { .chat-attention { animation: none; } }


/* v2.3.1 – administrace: stabilní vertikální scroll všech záložek bez zásahu do layoutu oddělení. */
body.admin-page {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.admin-page > nav {
    flex: 0 0 auto;
}

.admin-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.admin-main > #adminAlert,
.admin-main > .admin-tabs {
    flex: 0 0 auto;
}

.admin-tab-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.admin-tab-content > .tab-pane.active {
    min-height: 100%;
}

/* Tabulky si ponechávají vlastní horizontální scroll; vertikálně se posouvá obsah záložky. */
.admin-tab-content .table-responsive {
    overflow-x: auto;
}


/* v2.3.2 – jednotný inline editor v administraci. */
.admin-inline-editor-row > td {
    padding: .75rem !important;
    background: color-mix(in srgb, var(--fti-orange) 4%, var(--bs-body-bg));
}

.admin-editor-panel {
    border-color: color-mix(in srgb, var(--fti-orange) 45%, var(--bs-border-color)) !important;
}

.admin-editor-panel .card-header {
    background: color-mix(in srgb, var(--fti-orange) 8%, var(--bs-body-bg));
}

.machine-detail-row > td {
    padding: .75rem !important;
    background: color-mix(in srgb, var(--fti-orange) 2%, var(--bs-body-bg));
}
