@import url("./root.css");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-width: 100%;
    min-height: 100vh;
    display: flex;
    background-color: var(--white);
    flex-direction: column;
}

.nav-line-profile-container {
    width: calc(100% - 16px);
    height: 8vh;
    background-color: var(--red);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    padding-right: 5%;
    margin: 8px;
    border-radius: 10px;
}

.profile-box {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-user {
    color: var(--white);
    font-family: var(--text-style-trebuchet);
    font-size: 15px;
}

.profile-button {
    min-height: 32px;
    padding: 6px 18px;
    background-color: var(--white);
    color: #333;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    font-family: var(--text-style-trebuchet);
    font-size: 14px;
    cursor: pointer;
}

.main-container {
    display: grid;
    grid-template-columns: 1fr 6fr;
    width: calc(100% - 16px);
    flex: 1;
    min-height: 0;
    margin: 8px;
    gap: 10px;
}

.panel-container, .directory-container {
    background-color: var(--gray);
    border-radius: 20px;
}

.panel-container {
    display: flex;
    flex-direction: column;
    padding: 30px;
}

/* Пункты панели — <button>, поэтому нужен сброс стилей кнопки. */
.panel-item,
.panel-item-click {
    font-family: var(--text-style-trebuchet);
    margin-bottom: 30px;
    font-size: 20px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    color: inherit;
    line-height: 1.2;
}

.panel-item-click {
    color: var(--red);
}

.panel-item:focus-visible,
.panel-item-click:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}

.section-placeholder {
    font-family: var(--text-style-verdana);
    font-size: 15px;
    color: #666;
    padding: 20px 0;
}

.directory-container {
    padding: 10px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.header-directory-container {
    flex-shrink: 0;
}

.header-directory-container h1 {
    margin-bottom: 20px;
    font-family: var(--text-style-trebuchet);
}

.search-container {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
}

.search-container p {
    font-family: var(--text-style-trebuchet);
    font-size: 18px;
    margin-right: 5px;
    letter-spacing: 2px;
}

.search-container input[type="text"] {
    border: none;
    border-radius: 10px;
    width: 10%;
    font-size: 15px;
    padding: 3px;
    margin-right: 30px;
}

.search-button {
    width: 10%;
    min-width: 90px;
    height: 25px;
    background-color: var(--red);
    color: var(--white);
    border: none;
    border-radius: 5px;
    font-family: var(--text-style-trebuchet);
    font-size: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 30px;
    cursor: pointer;
}

.reset-filter-container {
    font-family: var(--text-style-verdana);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.add-button {
    margin-top: 30px;
    width: 15%;
    min-width: 120px;
    height: 30px;
    background-color: var(--red);
    color: var(--white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-family: var(--text-style-trebuchet);
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Контейнер для двух таблиц */
.tables-container {
    display: grid;
    grid-template-columns: 58% 43%;
    gap: 20px;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
    padding-right: 5px;
}

/* Обертка для каждой таблицы */
.table-wrapper {
    background: var(--white);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Добавляем отступ справа для правой таблицы */
.table-wrapper:last-child {
    margin-right: 0;
    padding-right: 0;
}

/* Заголовок второй таблицы */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px 8px 15px;
    flex-shrink: 0;
    gap: 10px;
    flex-wrap: wrap;
    background-color: var(--gray);
}

.table-title {
    font-family: var(--text-style-trebuchet);
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.loader-number {
    font-size: 13px;
    color: #555;
    font-family: var(--text-style-verdana);
}

.add-simple-button {
    background: var(--red);
    color: white;
    padding: 6px 20px;
    margin-top: 10px;
    font-family: var(--text-style-trebuchet);
    font-size: 14px;
    cursor: pointer;
    width: fit-content;
    flex-shrink: 0;
    border: none;
    transition: opacity 0.3s;
    border-radius: 10px;
}

/* Контейнер с прокруткой для таблицы */
.table-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100px;
    width: 100%;
    max-width: 100%;
}

/* Стили таблицы */
.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-scroll th {
    background: #f5f5f5;
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    font-family: var(--text-style-trebuchet);
    font-size: 10px;
    color: #333;
    border: 1px solid #ddd;
    border-top: none;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.table-scroll td {
    padding: 8px 10px;
    border: 1px solid #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    font-family: var(--text-style-trebuchet);
    text-align: center;
}

.td-btn-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.edit-btn, .delete-btn, .edit-downtime-btn, .delete-downtime-btn {
    background-color: transparent;
    border: none;
}

/* Ширина колонок для левой таблицы */
.table-wrapper:first-child .table-scroll th:nth-child(1),
.table-wrapper:first-child .table-scroll td:nth-child(1) {
    width: 10%;
    min-width: 60px;
}

.table-wrapper:first-child .table-scroll th:nth-child(2),
.table-wrapper:first-child .table-scroll td:nth-child(2) {
    width: 14%;
    min-width: 70px;
}

.table-wrapper:first-child .table-scroll th:nth-child(3),
.table-wrapper:first-child .table-scroll td:nth-child(3) {
    width: 12%;
    min-width: 70px;
}

.table-wrapper:first-child .table-scroll th:nth-child(4),
.table-wrapper:first-child .table-scroll td:nth-child(4) {
    width: 14%;
    min-width: 70px;
}

.table-wrapper:first-child .table-scroll th:nth-child(5),
.table-wrapper:first-child .table-scroll td:nth-child(5) {
    width: 10%;
    min-width: 60px;
}

.table-wrapper:first-child .table-scroll th:nth-child(6),
.table-wrapper:first-child .table-scroll td:nth-child(6) {
    width: 16%;
    min-width: 100px;
}

.table-wrapper:first-child .table-scroll th:nth-child(7),
.table-wrapper:first-child .table-scroll td:nth-child(7) {
    width: 14%;
    min-width: 70px;
}

.table-wrapper:first-child .table-scroll th:nth-child(8),
.table-wrapper:first-child .table-scroll td:nth-child(8) {
    width: 10%;
    min-width: 60px;
}

/* Ширина колонок для правой таблицы */
.table-wrapper:last-child .table-scroll th:nth-child(1),
.table-wrapper:last-child .table-scroll td:nth-child(1) {
    width: 11%;
    min-width: 50px;
}

.table-wrapper:last-child .table-scroll th:nth-child(2),
.table-wrapper:last-child .table-scroll td:nth-child(2) {
    width: 21%;
    min-width: 100px;
}

.table-wrapper:last-child .table-scroll th:nth-child(3),
.table-wrapper:last-child .table-scroll td:nth-child(3) {
    width: 21%;
    min-width: 100px;
}

.table-wrapper:last-child .table-scroll th:nth-child(4),
.table-wrapper:last-child .table-scroll td:nth-child(4) {
    width: 13%;
    min-width: 70px;
}

.table-wrapper:last-child .table-scroll th:nth-child(5),
.table-wrapper:last-child .table-scroll td:nth-child(5) {
    width: 24%;
    min-width: 90px;
}

.table-wrapper:last-child .table-scroll th:nth-child(6),
.table-wrapper:last-child .table-scroll td:nth-child(6) {
    width: 14%;
    min-width: 50px;
}

/* Строки таблицы */
.table-scroll tbody tr:nth-child(even) {
    background: #fafafa;
}

.table-scroll tbody tr:hover {
    background: #f5f5f5;
}

.table-scroll::-webkit-scrollbar {
    width: 8px;
    height: 0px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.table-scroll {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.table-scroll th {
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    font-size: 11px;
    padding: 6px 8px;
    text-align: center;
}

.table-scroll thead tr:first-child th {
    border-top: none;
}

.table-wrapper {
    min-height: 250px;
}

.table-scroll {
    min-height: 150px;
}

.table-scroll {
    overflow-y: scroll;
}

.tables-container {
    padding-right: 5px;
}

.directory-container {
    padding-right: 25px;
}

.table-scroll td input,
.table-scroll td select {
    width: 95%;
    max-width: 100%;
    padding: 6px 4px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: var(--text-style-verdana);
    font-size: 12px;
    text-align: center;
    background-color: #fff;
    box-sizing: border-box;
    transition: border-color 0.3s;
    word-wrap: break-word;
    white-space: normal;
    min-height: 30px;
}

.table-scroll td select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    padding-right: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

#add-row {
    background-color: #f9f9f9;
}

#add-row td {
    padding: 4px 2px;
    vertical-align: middle;
}

/* Стили для модального окна */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-container {
    background-color: var(--white);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px 15px 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.modal-header h2 {
    font-family: var(--text-style-trebuchet);
    font-size: 18px;
    color: #333;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.3s;
    line-height: 1;
}

.modal-body {
    padding: 25px 25px 20px 25px;
}

.modal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.modal-form-group {
    margin-bottom: 0;
}

.modal-form-group.full-width {
    grid-column: 1 / -1;
    margin-top: 5px;
}

.modal-form-group label {
    display: block;
    font-family: var(--text-style-trebuchet);
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.modal-form-group input[type="datetime-local"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: var(--text-style-verdana);
    font-size: 14px;
    transition: border-color 0.3s;
    background-color: #fafafa;
    box-sizing: border-box;
}

.modal-form-group input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--red);
    background-color: #fff;
}

.modal-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: var(--text-style-verdana);
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.3s;
    background-color: #fafafa;
    box-sizing: border-box;
    min-height: 100px;
}

.modal-form-group textarea:focus {
    outline: none;
    border-color: var(--red);
    background-color: #fff;
}

.modal-footer {
    padding: 15px 25px 25px 25px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    gap: 100px;
}

.modal-btn {
    padding: 10px 35px;
    border: none;
    font-family: var(--text-style-trebuchet);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.save-btn {
    background-color: var(--red);
    color: var(--white);
}

.save-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.cancel-btn {
    background-color: #f0f0f0;
    color: #555;
}

/* Выбранная строка. Селектор с .table-scroll tbody, иначе правило
   проигрывает по специфичности полосатой заливке tr:nth-child(even). */
.table-scroll tbody tr.selected,
.table-scroll tbody tr.selected:hover {
    background: #fdecec;
    box-shadow: inset 3px 0 0 var(--red);
}

.table-scroll tbody tr.editing {
    background: #fffdf2;
}

.table-scroll tbody tr[data-loader-id] {
    cursor: pointer;
}

/* Скрытие элементов вместо inline style="display:none" */
.is-hidden {
    display: none !important;
}

/* Сообщение об ошибке внутри модального окна.
   Класс использовался в скрипте, но в стилях его не было. */
.modal-error {
    display: none;
    margin-bottom: 15px;
    padding: 10px 12px;
    border-radius: 8px;
    background-color: #fdecec;
    border: 1px solid #f0b8b8;
    color: #8f1b1b;
    font-family: var(--text-style-verdana);
    font-size: 13px;
}

.modal-error.show {
    display: block;
}

/* Всплывающее уведомление вместо alert() */
.app-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    max-width: 360px;
    padding: 12px 18px;
    border-radius: 10px;
    color: var(--white);
    font-family: var(--text-style-trebuchet);
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.app-toast.is-error {
    background-color: var(--red);
}

.app-toast.is-success {
    background-color: #2e7d32;
}

/* ------------------------------------------------------------------ *
 * Страница входа
 * ------------------------------------------------------------------ */

.login-page {
    justify-content: center;
    align-items: center;
    background-color: var(--gray);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background-color: var(--white);
    padding: 35px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
}

.login-card h1 {
    font-family: var(--text-style-trebuchet);
    font-size: 20px;
    color: #333;
    margin-bottom: 4px;
}

.login-subtitle {
    font-family: var(--text-style-verdana);
    font-size: 13px;
    color: #777;
    margin-bottom: 22px;
}

.login-card label {
    font-family: var(--text-style-trebuchet);
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.login-card input {
    padding: 10px 12px;
    margin-bottom: 18px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: var(--text-style-verdana);
    font-size: 14px;
    background-color: #fafafa;
}

.login-card input:focus {
    outline: none;
    border-color: var(--red);
    background-color: var(--white);
}

.login-submit {
    margin-top: 6px;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background-color: var(--red);
    color: var(--white);
    font-family: var(--text-style-trebuchet);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.login-error {
    margin-bottom: 18px;
    padding: 10px 12px;
    border-radius: 8px;
    background-color: #fdecec;
    border: 1px solid #f0b8b8;
    color: #8f1b1b;
    font-family: var(--text-style-verdana);
    font-size: 13px;
}