/* ====================== Базовые стили и шрифты ====================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1a202c;
    background-color: #f8fafc;
    margin: 0;
    padding: 20px;
}

h1 {
    font-size: 1.6em;
    font-weight: 600;
    margin-bottom: 20px;
    color: #2d3748;
}

/* Управление элементами */
#controls {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

input, button {
    font-family: inherit;
    font-size: 0.95em;
}

button {
    cursor: pointer;
}

/* ====================== Контейнер таблицы ====================== */
.table-container {
    width: 100%;
    max-height: 80vh;              /* ограничиваем высоту таблицы */
    overflow-y: auto;              /* вертикальная прокрутка */
    overflow-x: auto;              /* горизонтальная прокрутка при большом диапазоне */
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    background-color: #fff;
}

/* ====================== Таблица ====================== */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    min-width: 900px;              /* чтобы колонки не схлопывались */
}

thead {
    background-color: #f1f5f9;
    position: sticky;              /* фиксируем заголовки */
    top: 0;
    z-index: 10;                   /* чтобы были поверх содержимого */
}

th, td {
    padding: 10px;
    text-align: center;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

th {
    font-weight: 600;
    background-color: #f9fafb;
}

/* ====================== Подсветка строки при наведении ====================== */
tr:hover td {
    background-color: #f9fafb;
}

/* ====================== Столбец с именами ====================== */
.animal-name {
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.species-common {
    font-size: 0.85em;
    color: #666;
}

.species-latin {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
}

/* ====================== Подсветка состояния (только ячейка имени) ====================== */
.state-good.animal-name {
    background-color: #c6f6d5;
}

.state-normal.animal-name {
    background-color: #fefcbf;
}

.state-bad.animal-name {
    background-color: #fed7d7;
}

/* ====================== Содержимое кормлений ====================== */
.feeding-contents {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
}

.feeding-contents li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.feeding-flags {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 45px; /* фиксированная ширина для иконок */
    flex-shrink: 0;
}

.flag {
    font-size: 1em;
    margin-right: 2px;
}

.feeding-text {
    flex: 1;
    text-align: left;
    font-size: 0.95em;
    color: #333;
}

/* ====================== Кнопки ====================== */
.add-feeding {
    background-color: #3182ce;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 0;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease;
}
.add-feeding:hover {
    background-color: #2b6cb0;
}

/* Кнопки редактирования и удаления */
.edit-feeding,
.delete-feeding {
    border: none;
    background: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.edit-feeding:hover,
.delete-feeding:hover {
    background-color: #f1f5f9;
    color: #000;
}

/* ====================== Модальное окно ====================== */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 320px;
    text-align: left;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    animation: fadeIn 0.2s ease;
}

.modal-content h3 {
    margin-top: 0;
}

#feedingContent {
    width: 100%;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95em;
    margin-bottom: 8px;
}

.modal-buttons {
    text-align: center;
    margin-top: 12px;
}

/* Круглые кнопки в модалке */
.circle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    font-size: 20px;
    margin: 0 6px;
    cursor: pointer;
    color: white;
}

.circle-btn.confirm {
    background-color: #48bb78;
}
.circle-btn.confirm:hover {
    background-color: #38a169;
}
.circle-btn.cancel {
    background-color: #e53e3e;
}
.circle-btn.cancel:hover {
    background-color: #c53030;
}

@keyframes fadeIn {
    from {opacity: 0; transform: scale(0.9);}
    to {opacity: 1; transform: scale(1);}
}
/* ====================== Статус животных ====================== */
.status-count {
    position: fixed;
    top: 80px;
    right: 20px;
    background-color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    font-size: 1em;
    z-index: 100;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-item .icon {
    font-size: 1.2em;
}

.status-pie-container {
    position: relative;
    width: 80px;
    height: 80px;
}

.status-pie {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
}

/* Tooltip */
.pie-tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 4px 7px;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    transform: translate(-50%, -100%);
}

/* Модалка добавления животного */
#animalModal .modal-content {
    width: 380px;
    max-height: 85vh;
    overflow-y: auto;
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#animalModal label {
    display: block;
    margin-top: 10px;
    font-weight: 500;
}

#animalModal input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.species-select-wrapper {
    display: flex;
    flex-direction: column;
}

#speciesSearch {
    margin-top: 5px;
    margin-bottom: 8px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

/* ====================== Поле выбора вида ====================== */
#animalSpecies {
    width: 100%;
    height: 36px;               /* фиксированная высота одной строки */
    line-height: 1.4;           /* выравнивание текста по вертикали */
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

#animalSpecies option {
    padding: 4px 6px;
}

.add-animal-cell {
    text-align: center;
    background: #f9fafb;
}

.add-animal-btn {
    width: 40px;
    height: 40px;
    font-size: 22px;
    border-radius: 50%;
    border: none;
    background-color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.add-animal-btn:hover {
    background-color: #cbd5e1;
}

#animalModal .modal-content {
    width: 380px;
    max-height: 85vh;
    overflow-y: auto;
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#animalModal label {
    display: block;
    margin-top: 10px;
    font-weight: 500;
}

#animalModal input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

/* Скрываем поле "Активен" по умолчанию */
#animalActiveContainer {
    display: none;
    margin-top: 10px;
}

.edit-animal-btn {
    float: right;
    margin-left: 6px;
    background: none;
    border: none;
    font-size: 16px;
    padding: 3px;
    cursor: pointer;
    color: #555;
}

.edit-animal-btn:hover {
    color: #000;
}

#topPanel {
    display: flex;
    justify-content: flex-end;
    padding: 10px 20px;
}

.small-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: #3b82f6;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

.small-btn:hover {
    background: #2563eb;
}

.user-panel {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 15px;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid #eee;
}

.top-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}

.top-btn:hover {
    background: #f3f3f3;
}

/* ====================== УФ-лампочки ====================== */
.uvbulb-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.uvbulb-panel {
    padding: 8px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9em;
    gap: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    cursor: default;
    position: relative;
}

.uvbulb-panel:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.uvbulb-content {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.uvbulb-resource {
    font-weight: 600;
    font-size: 1em;
    color: #2d3748;
}

.uvbulb-age {
    font-size: 1em;
    color: #666;
    font-weight: 500;
}

.uvbulb-no-data {
    padding: 8px;
    background-color: #f7fafc;
    border-radius: 6px;
    color: #718096;
    font-size: 0.85em;
    text-align: center;
    border: 1px dashed #cbd5e0;
}

.edit-uvbulb {
    border: none;
    background: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.edit-uvbulb:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: #000;
}

.add-uvbulb-btn {
    background-color: #3182ce;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 18px;
    line-height: 0;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease;
    align-self: flex-start;
    margin-top: 4px;
}

.add-uvbulb-btn:hover {
    background-color: #2b6cb0;
    transform: scale(1.1);
}

/* Тултип с датой установки */
.uvbulb-panel::after {
    content: attr(data-install-date);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background-color: #2d3748;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.uvbulb-panel:hover::after {
    opacity: 1;
}

.uvbulb-panel::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 4px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px 4px 0 4px;
    border-style: solid;
    border-color: #2d3748 transparent transparent transparent;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.uvbulb-panel:hover::before {
    opacity: 1;
}

/* Стили для новых полей УФ-лампочки */
#uvbulbPower,
#uvbulbType,
#uvbulbUvOutput {
    width: 100%;
    padding: 6px 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.uvbulb-description {
    font-size: 1em;
    color: #2d3748;
    font-weight: 600;
    margin-right: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /*max-width: 200px;*/
}

/* ====================== Фильтры с выпадающими списками ====================== */
#filtersContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
    padding: 12px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    align-items: center;
}

.filter-dropdown {
    position: relative;
    min-width: 200px;
}

.dropdown-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background-color: #fff;
    font-family: inherit;
    font-size: 0.95em;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dropdown-btn:hover {
    border-color: #a0aec0;
}

.dropdown-btn:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.dropdown-arrow {
    font-size: 0.7em;
    margin-left: 8px;
    transition: transform 0.2s;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background-color: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 300px;
    overflow: hidden;
}

.dropdown-content.show {
    display: block;
}

.dropdown-search {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.dropdown-search input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95em;
}

.dropdown-options {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

.dropdown-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-option:hover {
    background-color: #f1f5f9;
}

.dropdown-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.status-icon {
    margin-right: 6px;
    font-size: 1.1em;
}

/* Кнопки фильтров */
.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background-color: #3182ce;
    color: white;
    font-family: inherit;
    font-size: 0.95em;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.filter-btn:hover {
    background-color: #2b6cb0;
}

.filter-btn.clear-btn {
    background-color: #718096;
}

.filter-btn.clear-btn:hover {
    background-color: #4a5568;
}

/* Стили для выпадающего списка возраста */
#animalAge {
    width: 100%;
    padding: 6px 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background-color: #fff;
    cursor: pointer;
}

#animalAge:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Стили для форм с лейблами слева */
.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}

.form-row label {
    flex: 0 0 110px;
    text-align: right;
    font-weight: 500;
    color: #4a5568;
    font-size: 0.95em;
}

.form-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95em;
}

/* Увеличение ширины модального окна регистрации */
#registerModal .modal-content {
    width: 420px;
}

/* Кнопка добавления вида */
.add-species-btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    background-color: #e2e8f0;
    color: #4a5568;
    cursor: pointer;
    margin-right: 4px;
    transition: all 0.2s;
}

.add-species-btn:hover {
    background-color: #cbd5e0;
    color: #2d3748;
}

/* Стили для модального окна вида */
#speciesModal .modal-content {
    width: 380px;
}

#speciesModal label {
    display: block;
    margin-top: 12px;
    font-weight: 500;
    color: #4a5568;
}

#speciesModal input[type="text"],
#speciesModal select {
    width: 100%;
    padding: 6px 8px;
    margin-top: 5px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95em;
    box-sizing: border-box;
}

#speciesModal input[type="text"]:focus,
#speciesModal select:focus {
    border-color: #3182ce;
    outline: none;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}