/**
 * tableutil.css - Універсальні стилі для таблиць з ефектом парення
 * Стилі DataTable винесено в DataTable.css
 * Включає стилі для calendar-table та загальні парящі блоки
 */

/* ============================================
   ЗАГАЛЬНІ СТИЛІ ПАРЯЩИХ БЛОКІВ
   ============================================ */

/* Базовий парящий блок (заголовок, контроли) */
.floating-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.floating-header:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* Парящий блок для таблиці */
.floating-table-wrapper {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.floating-table-wrapper:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* ============================================
   CALENDAR-TABLE (таблиця календаря)
   ============================================ */

.calendar-container {
    padding: 20px;
}

/* Парящий блок контролів календаря */
.calendar-controls {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.calendar-controls:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.calendar-controls label {
    margin-right: 10px;
    font-weight: bold;
}

.calendar-controls select {
    padding: 8px;
    font-size: 16px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

.calendar-controls button {
    padding: 8px 20px;
    font-size: 16px;
    border-radius: 5px;
    border: 1px solid #04AA6D;
    background-color: #04AA6D;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

.calendar-controls button:hover {
    background-color: #039b5c;
}

/* Група навігації (кнопки + select) */
.calendar-nav-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Кнопки навігації (стрілки) */
.calendar-nav-btn {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    font-size: 20px !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav-btn:hover {
    transform: scale(1.1);
}

.calendar-scale {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-scale input[type="range"] {
    width: 150px;
    cursor: pointer;
}

/* Обгортка календаря */
.calendar-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.calendar-wrapper:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* Таблиця календаря */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
    font-size: 16px;
}

.calendar-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.calendar-table thead tr {
    background-color: #04AA6D;
    color: white;
}

.calendar-table th {
    padding: 15px;
    text-align: center;
    border: 1px solid #ddd;
    background-color: #04AA6D;
}

.calendar-table td {
    padding: 20px;
    text-align: center;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.calendar-table td:hover {
    background-color: #e0e0e0;
}

.calendar-table td.prev-month,
.calendar-table td.next-month {
    background-color: #f9f9f9;
    color: #999;
    cursor: default;
}

.calendar-table td.prev-month:hover,
.calendar-table td.next-month:hover {
    background-color: #f9f9f9;
}

.calendar-table td.today {
    background-color: #04AA6D;
    color: white;
    font-weight: bold;
}

.calendar-table td.today:hover {
    background-color: #039b5c;
}

/* ============================================
   СТАНИ ЗАВАНТАЖЕННЯ ТА ПОМИЛОК
   ============================================ */

.loading {
    text-align: center;
    padding: 50px;
    font-size: 18px;
    color: #666;
}

.loading i {
    margin-right: 10px;
    color: #007bff;
}

.error {
    text-align: center;
    padding: 50px;
    font-size: 18px;
    color: #dc3545;
    background: #fff;
    border-radius: 8px;
}

.error i {
    margin-right: 10px;
}

/* ============================================
   ПАНЕЛІ МЕНЮ ВІДДІЛЕННЯ
   ============================================ */

/* Контейнер меню відділення */
.department-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
}

/* Панель меню відділення */
.department-menu-panel {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease, background-color 0.3s ease, 
                opacity 0.3s ease, margin-top 0.6s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    user-select: none;
    position: relative;
}

/* Анімація переміщення */
.department-menu-panel.moving-down {
    animation: none;
}

.department-menu-panel.moving-up {
    animation: none;
}

/* Контейнер для таблиці - розкривається між панелями */
.department-content {
    margin-top: 10px;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.department-content.department-content-expanded {
    opacity: 1;
    transform: translateY(0);
}

/* Банер «дані змінено іншим користувачем» */
.stale-data-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin-bottom: 8px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    color: #664d03;
    font-size: 13px;
    animation: stale-banner-in 0.3s ease;
}
.stale-data-banner i.fa-info-circle { color: #e6a800; font-size: 15px; }
.stale-data-btn {
    margin-left: auto;
    padding: 4px 12px;
    border: 1px solid #ffc107;
    border-radius: 4px;
    background: #ffc107;
    color: #664d03;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.stale-data-btn:hover { background: #e6a800; }
.stale-data-close {
    border: none;
    background: none;
    font-size: 18px;
    line-height: 1;
    color: #997a00;
    cursor: pointer;
    padding: 0 4px;
}
.stale-data-close:hover { color: #664d03; }
@keyframes stale-banner-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.department-menu-panel:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
    background-color: #f0f7ff;
}

.department-menu-panel.active {
    background-color: #007bff;
    color: white;
}

.department-menu-panel.active:hover {
    background-color: #0056b3;
}

.department-menu-panel i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    color: #007bff;
}

.department-menu-panel.active i {
    color: white;
}

.department-menu-panel span {
    font-size: 16px;
    font-weight: 500;
}

/* Заголовок відділення (не клікабельний) */
.department-title-panel {
    background: white;
    cursor: default;
}

.department-title-panel:hover {
    transform: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: white;
}

.department-title-panel i {
    color: #007bff;
}

.department-title-panel h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

/* ============================================
   МОБІЛЬНА ВЕРСІЯ ПАНЕЛЕЙ МЕНЮ
   ============================================ */

@media screen and (max-width: 768px) {
    .department-menu {
        gap: 4px;
        margin-bottom: 4px;
    }

    .department-menu-panel {
        padding: 8px 6px;
        gap: 6px;
        border-radius: 4px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    }

    .department-menu-panel i {
        font-size: 16px;
        width: 18px;
    }

    .department-menu-panel span {
        font-size: 13px;
    }

    .department-content {
        margin-top: 4px;
        margin-bottom: 4px;
    }

    /* Відключити анімацію переміщення на мобільних */
    .department-menu-panel.moving-down,
    .department-menu-panel.moving-up {
        animation: none;
    }
    
    .department-menu-panel:hover {
        transform: none;
    }

    .floating-header {
        padding: 6px 4px;
        margin-bottom: 4px;
        border-radius: 4px;
    }

    .floating-table-wrapper {
        padding: 2px;
        border-radius: 4px;
    }

    .calendar-container {
        padding: 2px;
    }

    .calendar-controls {
        padding: 6px 4px;
        margin-bottom: 4px;
        gap: 6px;
        border-radius: 4px;
    }

    .calendar-wrapper {
        padding: 2px;
        border-radius: 4px;
    }

    .schedule-controls {
        padding: 6px 4px;
        border-radius: 4px;
    }

    .schedule-table-wrapper {
        border-radius: 4px;
    }

    .operations-controls {
        padding: 6px 4px;
        border-radius: 4px;
    }

    .consult-container {
        padding: 2px 0;
    }

    .consult-controls {
        gap: 4px;
        margin-bottom: 4px;
    }

    .consult-date-info {
        padding: 6px 8px;
        border-radius: 4px;
        margin-bottom: 4px;
    }
}

/* Ландшафтний режим - компактніше */
@media screen and (max-height: 500px) {
    .department-content {
        margin-top: 5px;
        margin-bottom: 5px;
    }
    
    .department-menu {
        margin-bottom: 5px;
    }
}

/* ============================================
   SCHEDULE TABLE (графік чергувань)
   ============================================ */

.schedule-container {
    width: 100%;
}

.schedule-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.schedule-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
}

.schedule-nav-btn:hover {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.schedule-nav-btn:active {
    transform: scale(0.95);
}

.schedule-select {
    padding: 8px 15px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.schedule-select:hover {
    border-color: #007bff;
}

.schedule-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

/* Overlay при завантаженні */
.schedule-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 100;
    gap: 10px;
}

.schedule-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.schedule-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-size: 13px;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid #e0e0e0;
    padding: 4px 3px;
    text-align: center;
    white-space: nowrap;
    min-width: 40px;
}

.schedule-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

/* Фіксовані колонки (Співробітник, Години) */
.schedule-table .sticky-col {
    position: sticky;
    background: #f5f5f5;
    z-index: 2;
}

.schedule-table .col-name {
    left: 0;
    min-width: 150px;
    max-width: 150px;
    text-align: left;
    padding-left: 12px;
}

/* Підсвічування співробітників з place=3 (блідо-рожевий) */
.schedule-table .col-name.place-3 {
    background: #FCE4EC;
}

.vacation-table .col-name.place-3 {
    background: #FCE4EC;
}

/* Виділення рядка при кліку */
.schedule-table tr.row-selected td {
    box-shadow: inset 0 2px 0 0 #e53935, inset 0 -2px 0 0 #e53935;
}

.schedule-table tr.row-selected td:first-child {
    box-shadow: inset 2px 2px 0 0 #e53935, inset 0 -2px 0 0 #e53935;
}

.schedule-table tr.row-selected td:last-child {
    box-shadow: inset 0 2px 0 0 #e53935, inset -2px -2px 0 0 #e53935;
}

/* Виділення обраних днів у режимі редагування */
.schedule-table td.day-selected {
    outline: 2px solid #1976D2 !important;
    outline-offset: -2px;
    background-color: rgba(25, 118, 210, 0.15) !important;
}

.schedule-table.schedule-locked tr.row-selected td[data-day] {
    cursor: pointer;
}

.schedule-table .col-hours {
    left: 150px;
    min-width: 60px;
}

.schedule-table tbody .sticky-col {
    background: white;
}

/* Фіксовані рядки (заголовок та кількість чергових) */
.schedule-table .sticky-row th,
.schedule-table .sticky-row td {
    position: sticky;
    z-index: 3;
}

.schedule-table .header-row th {
    top: 0;
}

.schedule-table .duty-count-row td {
    top: 42px; /* висота header-row */
    background: #fff3e0;
    font-weight: 600;
}

/* Кутові комірки (фіксовані і по X і по Y) */
.schedule-table .sticky-row .sticky-col {
    z-index: 4;
}

.schedule-table .duty-count-row .sticky-col {
    background: #fff3e0;
}

/* Вихідні дні (сб, нд) */
.schedule-table td.weekend {
    background: #f0f0f0;
    color: #666;
}


.schedule-table th.weekend {
    background: #e8e8e8 !important;
}

/* Ячейки з дежурством (для майбутнього) */
.schedule-table td.duty {
    background: #C8E6C9;
    color: #333;
}

.schedule-table td.duty.weekend {
    background: #A5D6A7;
}

/* Денна робота (duty=0) */
.schedule-table td.work {
    background: #BBDEFB;
    color: #333;
}

.schedule-table td.work.weekend {
    background: #90CAF9;
}

/* Відпустка (duty=-1) */
.schedule-table td.vacation {
    background: #FFCC80;
    color: #333;
    font-weight: bold;
}

.schedule-table td.vacation.weekend {
    background: #FFB74D;
}

/* Лікарняний (duty=-2) */
.schedule-table td.sick-leave {
    background: #FFCDD2;
    color: #333;
    font-weight: bold;
}

.schedule-table td.sick-leave.weekend {
    background: #EF9A9A;
}

/* Звільнено (duty=-3) */
.schedule-table td.fired {
    background: #CE93D8;
    color: #4A148C;
    font-weight: bold;
}

.schedule-table td.fired.weekend {
    background: #BA68C8;
    color: #4A148C;
}

/* Не прийнято (duty=-4) */
.schedule-table td.not-hired {
    background: #B0BEC5;
    color: #546E7A;
}

.schedule-table td.not-hired.weekend {
    background: #90A4AE;
    color: #37474F;
}

/* Побажання не ставити чергування (duty=2) */
.schedule-table td.no-schedule {
    background: #FFF9C4;
    color: #F57F17;
}

.schedule-table td.no-schedule.weekend {
    background: #FFF59D;
    color: #F57F17;
}

/* Ландшафтний режим для графіка */
@media screen and (max-height: 500px) {
    .schedule-controls {
        padding: 5px 10px;
        margin-bottom: 8px;
    }
    
    .schedule-select {
        padding: 5px 10px;
        font-size: 12px;
    }
    

    
    .schedule-table {
        font-size: 11px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 3px 2px;
        min-width: 30px;
    }
    
    .schedule-table .col-name {
        min-width: 100px;
        max-width: 100px;
    }
    
    .schedule-table .col-hours {
        left: 100px;
        min-width: 40px;
    }
    
    /* Менший sticky header row */
    .schedule-table .duty-count-row td {
        top: 32px;
    }
}

/* Fullscreen для графіка */
body.fullscreen-mode .schedule-table-wrapper {
    overflow-x: auto;
}

@media screen and (max-height: 500px) {
    body.fullscreen-mode .schedule-container {
        height: calc(100vh - 50px);
        display: flex;
        flex-direction: column;
    }
    
    body.fullscreen-mode .schedule-table-wrapper {
        flex: 1;
        overflow: auto;
    }
    
}

/* ============================================
   VACATION TABLE (графік відпусток)
   ============================================ */

.vacation-container {
    width: 100%;
}

.vacation-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Overlay при завантаженні */
.vacation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 100;
    gap: 10px;
}

.vacation-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

.vacation-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-size: 13px;
}

.vacation-table th,
.vacation-table td {
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
    text-align: center;
    white-space: nowrap;
}

.vacation-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

/* Фіксовані колонки */
.vacation-table .sticky-col {
    position: sticky;
    background: #f5f5f5;
    z-index: 2;
}

.vacation-table .col-name {
    left: 0;
    min-width: 180px;
    max-width: 180px;
    text-align: left;
    padding-left: 12px;
    cursor: pointer;
}

.vacation-table .col-days {
    left: 180px;
    min-width: 50px;
    max-width: 50px;
    font-weight: 600;
}

.vacation-table tbody .sticky-col {
    background: white;
}

/* Заголовок рядка */
.vacation-table .header-row th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.vacation-table .header-row .sticky-col {
    z-index: 4;
}

/* Місячні комірки */
.vacation-table .month-header {
    min-width: 70px;
}

.vacation-table .month-cell {
    min-width: 70px;
    font-size: 11px;
    color: #666;
}

/* Комірки з даними - базовий стиль */
.vacation-table .month-cell[style] {
    font-weight: 600;
    color: #333;
}

/* Клікабельні заголовки місяців */
.vacation-table .month-header.clickable {
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.vacation-table .month-header.clickable:hover {
    background: #1976D2;
    color: white;
}

/* Місячний вигляд - заголовок */
.vacation-month-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    padding: 0 15px;
}

/* Місячний вигляд - комірки днів */
.vacation-table.vacation-month-view .day-header {
    min-width: 32px;
    max-width: 32px;
    font-size: 12px;
    padding: 4px 2px;
}

.vacation-table.vacation-month-view .day-header.weekend {
    background: #e0e0e0;
    color: #666;
}

.vacation-table.vacation-month-view .day-cell {
    min-width: 32px;
    max-width: 32px;
    font-size: 10px;
    padding: 4px 2px;
}

.vacation-table.vacation-month-view .day-cell.weekend {
    background: #f5f5f5;
}

.vacation-table.vacation-month-view .day-cell[style] {
    font-weight: 600;
}

/* Рядок підрахунку кількості у відпустках */
.vacation-table.vacation-month-view .vacation-count-row td {
    position: sticky;
    top: 32px;
    background: #FFF3E0;
    font-weight: 600;
    color: #E65100;
    z-index: 3;
}

.vacation-table.vacation-month-view .vacation-count-row .sticky-col {
    z-index: 4;
    background: #FFF3E0;
}

.vacation-table.vacation-month-view .vacation-count-row td.weekend {
    background: #FFE0B2;
}

/* Виділення рядка при кліку */
.vacation-table tr.row-selected td {
    box-shadow: inset 0 2px 0 0 #1976D2, inset 0 -2px 0 0 #1976D2;
}

.vacation-table tr.row-selected td:first-child {
    box-shadow: inset 2px 2px 0 0 #1976D2, inset 0 -2px 0 0 #1976D2;
}

.vacation-table tr.row-selected td:last-child {
    box-shadow: inset 0 2px 0 0 #1976D2, inset -2px -2px 0 0 #1976D2;
}

/* ============================================
   VACATION TABLE - FULLSCREEN MODE
   ============================================ */

body.fullscreen-mode .vacation-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

body.fullscreen-mode .vacation-table-wrapper {
    flex: 1;
    max-height: none;
}

body.fullscreen-mode .vacation-controls {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 9999;
    margin-bottom: 0;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Мобільний горизонтальний fullscreen */
@media screen and (max-height: 500px) {
    body.fullscreen-mode .vacation-container {
        height: calc(100vh - 50px);
        padding-top: 45px;
    }
    
    body.fullscreen-mode .vacation-table-wrapper {
        flex: 1;
        max-height: none;
        overflow: auto;
    }
    
    body.fullscreen-mode .vacation-controls {
        top: 5px;
        left: 5px;
        padding: 4px 8px;
    }
    
    body.fullscreen-mode .vacation-table {
        font-size: 11px;
    }
    
    body.fullscreen-mode .vacation-table th,
    body.fullscreen-mode .vacation-table td {
        padding: 3px 4px;
    }
    
    body.fullscreen-mode .vacation-table .col-name {
        min-width: 140px;
        max-width: 140px;
    }
    
    body.fullscreen-mode .vacation-table .col-days {
        left: 140px;
        min-width: 40px;
        max-width: 40px;
    }
}

/* ============================================
   MCARD TABLE (медичні карти)
   ============================================ */

.mcard-container {
    width: 100%;
}

.mcard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mcard-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.mcard-header h3 i {
    margin-right: 8px;
    color: #2196F3;
}

.mcard-filters {
    display: flex;
    gap: 10px;
    align-items: center;
}

.mcard-filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.mcard-filter-select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Overlay при завантаженні */
.mcard-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 100;
    gap: 10px;
}

#mcardsTableWrapper {
}

/* ============================================
   OPERATIONS TABLE (графік операцій)
   ============================================ */

.operations-container {
    width: 100%;
}

.operations-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.operations-date-picker {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.operations-date-picker:hover {
    border-color: #007bff;
}

.operations-date-picker:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.operations-today-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: all 0.2s;
    white-space: nowrap;
}

.operations-today-btn:hover {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.operations-date-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    margin-bottom: 10px;
    background: #e3f2fd;
    border-radius: 6px;
    font-size: 14px;
    color: #1565c0;
}

.operations-date-info.weekend {
    background: #fce4ec;
    color: #c62828;
}

.operations-date-text {
    font-weight: 600;
    font-size: 15px;
}

.operations-total-count {
    font-size: 14px;
    font-weight: 600;
    color: #1565c0;
    margin-left: 12px;
}

.operations-stats {
    font-size: 13px;
    opacity: 0.8;
}

.operations-table-wrapper {
}

.operations-no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.operations-no-data i {
    margin-right: 8px;
    font-size: 18px;
}

/* Єдина таблиця операцій */
.operations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.operations-table thead th {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-top: none;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.operations-table tbody td {
    padding: 7px 10px;
    border: 1px solid #e0e0e0;
    color: #333;
    vertical-align: top;
}

.operations-table tbody tr:hover td:not(.operations-unit-cell) {
    background: #f5f9ff;
}

.operations-table tbody tr.selected td:not(.operations-unit-cell) {
    background: #e3f0fd;
}

.operations-table tbody tr.selected:hover td:not(.operations-unit-cell) {
    background: #d4e8fa;
}

/* Комірка відділення (rowspan) */
.operations-table .operations-unit-cell {
    background: white;
    color: #333;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 12px;
    vertical-align: middle;
    text-align: left;
    border: 1px solid #e0e0e0;
    min-width: 140px;
    max-width: 200px;
    white-space: normal;
    line-height: 1.3;
    position: sticky;
    left: 0;
    z-index: 1;
}

.operations-unit-count {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #1565c0;
    margin-top: 4px;
}

/* Розділювач між відділеннями */
.operations-table tbody tr.operations-unit-first-row td {
    border-top: 2px solid #e0e0e0;
}

/* Sticky заголовок колонки "Відділення" */
.operations-table thead th.operations-unit-th {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #e8eaf6;
    min-width: 140px;
}

/* Overlay */
.operations-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 100;
    gap: 10px;
}

/* Fullscreen для графіка операцій */
body.fullscreen-mode .operations-table-wrapper {
    overflow-x: auto;
}

/* Адаптивність */
@media screen and (max-width: 768px) {
    .operations-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .operations-date-info {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
    
    .operations-table {
        font-size: 12px;
    }
    
    .operations-table thead th,
    .operations-table tbody td {
        padding: 5px 6px;
    }
    
    .operations-table .operations-unit-cell {
        min-width: 100px;
        max-width: 140px;
        font-size: 12px;
        padding: 6px 8px;
    }
}

@media screen and (max-height: 500px) {
    .operations-table-wrapper {
        max-height: none;
    }
    
    .operations-controls {
        padding: 5px 10px;
        margin-bottom: 5px;
    }
}

/* ═══════════════════════════════════════
   КОНСУЛЬТАЦІЇ
   ═══════════════════════════════════════ */

.consult-container {
    padding: 10px 15px;
    position: relative;
}

.consult-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.consult-date-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #e8f5e9;
    border-radius: 8px;
    margin-bottom: 10px;
}

.consult-date-info.weekend {
    background: #fff3e0;
}

.consult-date-text {
    font-weight: 600;
    font-size: 15px;
}

.consult-total-count {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
    margin-left: 12px;
}

.consult-section {
    margin-bottom: 20px;
}

.consult-section:last-child {
    margin-bottom: 0;
}

.consult-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    border-left: 3px solid #2e7d32;
}

.consult-section-title i {
    margin-right: 6px;
    color: #2e7d32;
}

.consult-section-count {
    font-weight: 700;
    color: #2e7d32;
}

.consult-table-wrapper {
}

.consult-no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.consult-no-data i {
    margin-right: 8px;
    font-size: 18px;
}

.consult-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.consult-table thead th {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-top: none;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.consult-table tbody td {
    padding: 7px 10px;
    border: 1px solid #e0e0e0;
    color: #333;
    vertical-align: top;
}

.consult-table tbody tr:hover td {
    background: #f5f9ff;
}

.consult-table tbody tr.selected td {
    background: #e3f0fd;
}

.consult-table tbody tr.selected:hover td {
    background: #d4e8fa;
}

.consult-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    z-index: 100;
    gap: 10px;
}

/* Fullscreen */
body.fullscreen-mode .consult-table-wrapper {
    overflow-x: auto;
}

@media screen and (max-width: 768px) {
    .consult-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .consult-date-info {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
    
    .consult-table {
        font-size: 12px;
    }
    
    .consult-table thead th,
    .consult-table tbody td {
        padding: 5px 6px;
    }
}

/* Іконка реанімації біля номера карти */
.icu-icon {
    color: #e74c3c;
    margin-left: 4px;
    font-size: 0.9em;
    animation: icu-pulse 1.5s ease-in-out infinite;
}

@keyframes icu-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Іконки консультацій та операцій біля номера карти */
.cons-icon {
    color: #e67e22;
    margin-left: 4px;
    font-size: 0.9em;
}
.oper-icon {
    color: #8e44ad;
    margin-left: 4px;
    font-size: 0.9em;
}
.cons-count {
    color: #e67e22;
    margin-left: 1px;
    font-size: 0.8em;
    font-weight: 700;
}
.oper-count {
    color: #8e44ad;
    margin-left: 1px;
    font-size: 0.8em;
    font-weight: 700;
}

/* Іконка статі після ФІО */
.sex-male {
    color: #3498db;
    margin-left: 4px;
    font-size: 0.9em;
}
.sex-female {
    color: #e84393;
    margin-left: 4px;
    font-size: 0.9em;
}
.patient-age {
    color: #7f8c8d;
    margin-left: 3px;
    font-size: 0.85em;
}