/* ========== style.css – гостевая страница (PT Sans Narrow, фикс колонок) ========== */

/* ---------- ПОДКЛЮЧЕНИЕ ШРИФТА PT Sans Narrow ---------- */
@font-face {
    font-family: 'PT Sans Narrow';
    src: url('fonts/PTSansNarrow-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PT Sans Narrow';
    src: url('fonts/PTSansNarrow-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* принудительное наследование шрифта для всех форм */
button,
input,
select,
textarea {
    font-family: inherit !important;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    transition: all ease-in-out 0.1s;
}

/* ===== СВЕТЛАЯ ТЕМА ===== */
:root {
    --bg-gradient: linear-gradient(145deg, #ffdab9, #f4a460);
    --container-bg: #fffff0;
    --section-bg: linear-gradient(145deg, #ffebcd, #f4a460);
    --card-bg: linear-gradient(145deg, #ffdab9, #f4a460);
    --btn-primary: linear-gradient(145deg, #ffb347, #ff8c00);
    --btn-primary-hover: linear-gradient(145deg, #ffa500, #ff7f00);
    --btn-login: linear-gradient(145deg, #ffcc99, #ffaa66);
    --btn-login-hover: linear-gradient(145deg, #ffbb88, #ff9955);
    --btn-active: linear-gradient(145deg, #cc5500, #aa4400);
    --btn-active-hover: linear-gradient(145deg, #dd6600, #bb5500);
    --btn-delete: #dc143c;
    --btn-delete-hover: #b22222;
    --message-success: linear-gradient(145deg, #ffb347, #ff8c00);
    --message-error: linear-gradient(145deg, #ff6b6b, #ff4444);
    --text-color: #000;
    --border-color: #000;
    --input-bg: white;
    --modal-bg: #fff;
    --floating-bg: rgba(78, 150, 245, 0.95);
    --type-selected: #cc5500;
    --type-selected-dark: #aa4400;
    --message-info: #000000;
    --message-error: #8b0000;
    --icon-color: black;
    --link-color: #0066cc;
    --link-hover-color: #004499;
    --modal-overlay: rgba(15, 25, 40, 0.75);
}

/* ===== ТЁМНАЯ ТЕМА (синяя гамма) ===== */
body.dark-theme {
    --bg-gradient: linear-gradient(145deg, #080c25, #161e35);
    --container-bg: #080c25;
    --section-bg: linear-gradient(145deg, #161e35, #293659);
    --card-bg: linear-gradient(145deg, #293659, #3071e7);
    --btn-primary: linear-gradient(145deg, #293659, #3071e7);
    --btn-primary-hover: linear-gradient(145deg, #3071e7, #a6b2ec);
    --btn-login: linear-gradient(145deg, #293659, #3071e7);
    --btn-login-hover: linear-gradient(145deg, #3071e7, #a6b2ec);
    --btn-active: linear-gradient(145deg, #3071e7, #293659);
    --btn-active-hover: linear-gradient(145deg, #a6b2ec, #3071e7);
    --btn-delete: linear-gradient(145deg, #b55a3a, #8a4a2a);
    --btn-delete-hover: linear-gradient(145deg, #c56a4a, #9a5a3a);
    --message-success: linear-gradient(145deg, #293659, #3071e7);
    --message-error: linear-gradient(145deg, #b55a3a, #8a4a2a);
    --text-color: #f0f0f0;
    --border-color: #3071e7;
    --input-bg: #161e35;
    --modal-bg: #080c25;
    --floating-bg: rgba(48, 113, 231, 0.95);
    --type-selected: #3071e7;
    --type-selected-dark: #293659;
    --message-info: #a6b2ec;
    --message-error: #ff6b6b;
    --icon-color: white;
    --link-color: #66b0ff;
    --link-hover-color: #99ccff;
    --modal-overlay: rgba(15, 25, 40, 0.85);
    background: var(--bg-gradient);
}

/* ===== БАЗОВЫЕ СТИЛИ ===== */
html {
    background: var(--bg-gradient);
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    width: 100%;
    font-size: 16px;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    background: transparent;
    min-height: 100vh;
    font-family: 'PT Sans Narrow', Arial, sans-serif !important;
    /* ← PT Sans Narrow */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    color: var(--text-color);
}

.main-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    opacity: 0;
    animation: fadeIn 0.2s ease-in forwards;
    width: 100%;
    max-width: 1100px;
    background-color: var(--container-bg);
    padding: 15px;
    border: 3px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    align-self: center;
    overflow-x: hidden;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

header {
    margin-bottom: 15px;
}

/* ===== ХЕДЕР ===== */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

h1 {
    margin: 0;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    color: var(--text-color);
    font-size: 1.5rem;
    flex: 1;
    min-width: 200px;
}

.mobile-break {
    display: inline;
}

.contact-buttons-left {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.action-buttons-right {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.contact-btn,
.auth-btn,
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
    transition:
        transform 0.1s ease,
        background-color 0.1s ease;
    aspect-ratio: 1 / 1;
    width: 40px;
    height: 40px;
    background: var(--btn-primary);
    color: black;
}

.contact-btn:hover,
.auth-btn:hover,
.theme-toggle-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background: var(--btn-primary-hover);
}

body.dark-theme .contact-btn,
body.dark-theme .auth-btn,
body.dark-theme .theme-toggle-btn {
    color: white;
}

body.dark-theme .contact-btn:hover,
body.dark-theme .auth-btn:hover,
body.dark-theme .theme-toggle-btn:hover {
    background: var(--btn-primary-hover);
}

.telegram-btn {
    background-color: #0088cc;
    color: white;
}

.telegram-btn:hover {
    background-color: #0077b3;
}

.email-btn {
    background-color: #d44638;
    color: white;
}

.email-btn:hover {
    background-color: #c1351d;
}

.login-btn {
    background-color: #009926;
    color: white;
}

.login-btn:hover {
    background-color: #004e23;
}

.register-btn {
    background-color: #ff9800;
    color: white;
}

.register-btn:hover {
    background-color: #e68900;
}

.contact-icon,
.auth-icon,
.theme-icon {
    font-size: 20px;
    line-height: 1;
}

.contact-text,
.auth-text {
    display: none;
}

/* Кнопка установки PWA */
.install-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
    transition:
        transform 0.1s ease,
        background-color 0.1s ease;
    aspect-ratio: 1 / 1;
    width: 40px;
    height: 40px;
    background: var(--btn-primary);
    color: black;
    cursor: pointer;
}

.install-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background: var(--btn-primary-hover);
}

body.dark-theme .install-btn {
    color: white;
}

.install-icon {
    font-size: 20px;
    line-height: 1;
}

.install-text {
    display: none;
}

/* ===== ОСНОВНОЙ БЛОК ===== */
.allAboutProducts {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 15px;
    background: var(--section-bg);
}

.aboutProducts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-bottom: 12px;
}

.types-control {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.types-control button {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    min-height: 30px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    transition: background 0.1s ease;
    background: var(--btn-primary);
    color: black;
    height: 48px;
}

body.dark-theme .types-control button {
    color: white;
}

.types-control button:hover {
    background: var(--btn-primary-hover);
}

.showTypesBtn {
    background-color: rgb(0, 108, 209);
}

.confirmTypesBtn {
    background-color: rgb(0, 128, 21);
    display: none;
}

.clearTypesBtn {
    background-color: rgb(212, 103, 0);
}

/* ===== КОНТЕЙНЕР ТИПОВ ===== */
.types-container {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
}

.type {
    padding: 8px 6px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-color);
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    min-height: 30px;
    height: auto;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.type:hover {
    background: var(--btn-primary-hover);
    color: var(--text-color);
}

.type.selected {
    background: var(--type-selected);
    color: white;
}

.type.selected:hover {
    background: var(--type-selected-dark);
}

body.dark-theme .type.selected {
    background: var(--type-selected);
    color: white;
}

body.dark-theme .type.selected:hover {
    background: var(--type-selected-dark);
}

.selected-types-container {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    overflow: visible;
}

.selected-type {
    padding: 8px 6px !important;
    font-size: 12px !important;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: var(--btn-primary);
    color: black;
    white-space: normal !important;
    word-wrap: break-word !important;
    min-height: 30px !important;
    height: auto !important;
    text-align: center;
    min-width: 0;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.selected-type:hover {
    background: var(--btn-primary-hover);
    color: var(--text-color);
}

.selected-type.active {
    background-color: #009ccc;
    color: black;
}

.selected-type.active:hover {
    background-color: #0077b3;
}

.selected-type.clear-active-type {
    background-color: #ff6b6b;
    color: white;
}

.selected-type.clear-active-type:hover {
    background-color: #ff5252;
}

body.dark-theme .selected-type {
    background: var(--btn-primary);
    color: white;
}

body.dark-theme .selected-type.active {
    background-color: #0077b3;
    color: white;
}

body.dark-theme .selected-type.clear-active-type {
    background: var(--btn-delete);
    color: white;
}

body.dark-theme .selected-type.clear-active-type:hover {
    background: var(--btn-delete-hover);
}

.selected-type[data-value]:not(.clear-active-type) {
    background: var(--type-selected);
    color: white;
}

.selected-type[data-value]:not(.clear-active-type):hover {
    background: var(--type-selected-dark);
}

body.dark-theme .selected-type[data-value]:not(.clear-active-type) {
    background: var(--type-selected);
}

body.dark-theme .selected-type[data-value]:not(.clear-active-type):hover {
    background: var(--type-selected-dark);
}

/* ===== ВВОД ДАННЫХ ===== */
.inputProducts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.inputName {
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#inputName,
#inputValue,
#inputUnit {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
    line-height: normal;
    box-sizing: border-box;
}

#inputValue {
    font-family: 'PT Sans Narrow', sans-serif;
    letter-spacing: 0.5px;
}

#inputUnit {
    appearance: none;
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="black" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

body.dark-theme #inputUnit {
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
}

.inputValues {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    width: 100%;
    align-items: stretch;
}

.calculator-button-container {
    width: 100%;
    margin-top: 5px;
}

.calculator-btn {
    width: 100%;
    height: 48px;
    padding: 0 15px;
    background: var(--btn-primary);
    color: black;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition:
        background 0.2s,
        transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-theme .calculator-btn {
    color: white;
}

.calculator-btn:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
}

.compact-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.sortBtn,
.addToTableBtn {
    padding: 0;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    height: 48px;
    font-weight: bold;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sortBtn {
    background: var(--btn-primary);
    color: black;
}

.sortBtn:hover {
    background: var(--btn-primary-hover);
}

body.dark-theme .sortBtn {
    color: white;
}

.addToTableBtn {
    background: var(--btn-primary);
    color: black;
}

.addToTableBtn:hover {
    background: var(--btn-primary-hover);
}

body.dark-theme .addToTableBtn {
    color: white;
}

.addBtn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.excelBtn,
.clearTable {
    padding: 0;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    height: 48px;
    font-weight: bold;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.excelBtn {
    background: var(--btn-primary);
    color: black;
}

.excelBtn:hover {
    background: var(--btn-primary-hover);
}

body.dark-theme .excelBtn {
    color: white;
}

.clearTable {
    background: var(--btn-delete);
    color: white;
}

.clearTable:hover {
    background: var(--btn-delete-hover);
}

/* ===== ТАБЛИЦА (гостевая) ===== */
.table {
    width: 100%;
    font-size: 15px;
    table-layout: fixed;
    background-color: transparent;
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-collapse: collapse;
    color: var(--text-color);
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 8px 6px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-color: transparent;
}

th {
    background: var(--card-bg);
    font-weight: bold;
}

td {
    background: var(--section-bg);
}

/* ---------- ШИРИНЫ КОЛОНОК ГОСТЕВОЙ ТАБЛИЦЫ ---------- */
/* Базовые (≤320px) – таблица гарантированно помещается в контейнер */
@media (max-width: 320px) {
    .t-name {
        width: 100px;
    }

    .t-type {
        width: 40px;
    }

    .t-value {
        width: 60px;
    }

    .t-delete {
        width: 80px;
    }
}

/* Пропорциональные (>320px) */
@media (min-width: 321px) {
    .t-name {
        width: 42.857%;
    }

    .t-type {
        width: 12.698%;
    }

    .t-value {
        width: 19.048%;
    }

    .t-delete {
        width: 25.397%;
    }
}

/* ---------- КНОПКИ ДЕЙСТВИЙ ---------- */
.action-buttons {
    display: flex;
    gap: 4px;
    /* строго 4px */
    justify-content: center;
    align-items: center;
    width: 100%;
}

.editBtn,
.deleteBtn {
    height: 36px;
    width: 36px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    padding: 0;
    font-size: 16px;
    flex-shrink: 0;
    margin: 0;
}

.editBtn {
    background: var(--card-bg);
    color: var(--text-color);
}

.editBtn:hover {
    background: var(--btn-primary-hover);
    color: white;
}

.deleteBtn {
    background: var(--btn-delete);
    color: white;
}

.deleteBtn:hover {
    background: var(--btn-delete-hover);
}

.edit-text,
.delete-text {
    display: none !important;
}

.edit-icon,
.delete-icon {
    display: inline !important;
}

/* ===== ТЕКСТОВОЕ ПРЕДУПРЕЖДЕНИЕ ===== */
.textWarn {
    text-align: center;
    margin: 15px 10px;
    font-size: 15px;
    display: block;
    background: transparent;
    border: none;
    padding: 0;
    color: var(--message-info);
}

.textWarn.success {
    color: var(--message-info);
}

.textWarn.error {
    color: var(--message-error);
}

.textWarn.warning {
    color: var(--message-info);
}

.textWarn.info {
    color: var(--message-info);
}

.undo-btn {
    background: none;
    border: none;
    color: var(--btn-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    margin-left: 8px;
    padding: 0;
    font-weight: bold;
}

.undo-btn:hover {
    color: var(--btn-primary-hover);
}

/* ===== ПОДСКАЗКИ ===== */
.suggestions-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 0 0 12px 12px;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
}

.suggestion-item {
    padding: 12px 20px;
    margin: 2px 4px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-color);
    border-radius: 8px;
    transition: background-color 0.2s;
    word-break: break-word;
}

.suggestion-item:hover {
    background-color: rgba(128, 128, 128, 0.2);
}

.suggestion-item.active {
    background-color: var(--btn-primary);
    color: white;
}

.suggestion-item strong {
    font-weight: bold;
    color: var(--btn-primary-hover);
}

.suggestion-item.active strong {
    color: #ffdd00;
}

/* ===== ПЛАВАЮЩЕЕ ПОЛЕ (КНОПКА НАВЕРХ) ===== */
.floating-name-field {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--floating-bg);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    padding: 8px;
    width: auto;
    min-width: 0;
    z-index: 999;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-name-field.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.floating-name-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.go-to-top-btn {
    background: var(--btn-primary);
    color: var(--text-color);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    outline: none;
}

.go-to-top-btn:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.1);
}

.go-to-top-btn:focus {
    outline: none;
}

/* ===== СТРОКА ПОИСКА ===== */
.search-container {
    display: flex;
    position: relative;
    margin: 15px 0;
    width: 100%;
}

.search-input {
    flex: 1;
    height: 48px;
    padding: 0 40px 0 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: all 0.2s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(78, 150, 245, 0.3);
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--btn-delete);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.clear-search-btn:hover {
    background: var(--btn-delete-hover);
}

/* ===== КНОПКА ОТМЕНЫ РЕДАКТИРОВАНИЯ И ПОДТВЕРЖДЕНИЯ ===== */
.cancel-edit-container {
    display: flex;
    gap: 8px;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    animation: slideInDown 0.3s ease forwards;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cancelEditBtn,
.confirmEditBtn {
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s;
    height: 40px;
}

.confirmEditBtn {
    background-color: #4caf50;
    color: white;
}

.confirmEditBtn:hover {
    background-color: #45a049;
}

.cancelEditBtn {
    background-color: #ff4444;
    color: white;
}

.cancelEditBtn:hover {
    background-color: #cc0000;
}

body.dark-theme .confirmEditBtn {
    background-color: #2e7d32;
}

body.dark-theme .confirmEditBtn:hover {
    background-color: #1b5e20;
}

body.dark-theme .cancelEditBtn {
    background-color: #b71c1c;
}

body.dark-theme .cancelEditBtn:hover {
    background-color: #8b0000;
}

/* ===== КАЛЬКУЛЯТОР ===== */
.calculator-modal {
    display: none;
    position: fixed;
    background-color: var(--modal-bg);
    border: 3px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    width: 280px;
    max-width: 90vw;
    z-index: 2000;
    overflow: hidden;
    flex-direction: column;
    backdrop-filter: blur(5px);
    transition-property: opacity, visibility;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

.calculator-modal.visible {
    display: flex !important;
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--btn-primary);
    color: black;
    border-bottom: 2px solid var(--border-color);
    cursor: grab;
    user-select: none;
}

body.dark-theme .calculator-header {
    color: white;
}

.calculator-header:active {
    cursor: grabbing;
}

.calculator-title {
    font-weight: bold;
    font-size: 15px;
}

.close-calculator-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-calculator-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.calculator-display {
    padding: 12px;
    background-color: white;
    border-bottom: 2px solid var(--border-color);
}

#calculatorDisplay {
    width: 100%;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 18px;
    font-family: 'PT Sans Narrow', sans-serif;
    text-align: right;
    padding: 0 10px;
    background-color: #f9f9f9;
    color: #000;
    box-sizing: border-box;
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 12px;
    background-color: #e0e0e0;
}

.calc-btn {
    height: 48px;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    user-select: none;
}

.calc-btn:hover {
    background-color: #f0f0f0;
    transform: scale(0.98);
}

.calc-btn[data-value="C"] {
    background-color: #ff4444;
    color: white;
}

.calc-btn[data-value="="] {
    background-color: var(--btn-primary);
    color: black;
    grid-column: span 2;
}

body.dark-theme .calc-btn[data-value="="] {
    color: white;
}

.calculator-backspace {
    padding: 0 12px 12px 12px;
    background-color: #e0e0e0;
}

.calculator-backspace .calc-btn {
    width: 100%;
    height: 48px;
}

/* ===== ОБЩИЕ СТИЛИ ДЛЯ МОДАЛЬНЫХ ОКОН ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.25s ease;
}

.modal-content {
    background-color: var(--modal-bg);
    padding: 24px;
    border-radius: 28px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0, 20, 40, 0.25);
    border: 2px solid var(--border-color);
    position: relative;
    margin: 0 auto;
    color: var(--text-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--text-color);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.modal-close-btn:hover {
    background-color: rgba(128, 128, 128, 0.2);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-actions .btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    height: 48px;
    background: var(--btn-primary);
    color: var(--text-color);
    transition:
        background 0.1s ease,
        transform 0.1s ease;
    white-space: nowrap;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.modal-actions .btn:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.02);
}

.modal-actions .btn-delete {
    background: var(--btn-delete);
    color: white;
}

.modal-actions .btn-delete:hover {
    background: var(--btn-delete-hover);
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
    margin-bottom: 16px;
    box-sizing: border-box;
}

.modal-content textarea {
    min-height: 100px;
    resize: vertical;
}

.modal-content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px dashed var(--border-color);
    transition:
        color 0.2s,
        border-bottom-color 0.2s;
}

.modal-content a:hover {
    color: var(--link-hover-color);
    border-bottom: 1px solid var(--link-hover-color);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }

    to {
        opacity: 1;
        backdrop-filter: blur(5px);
    }
}

/* ===== БУРГЕР-МЕНЮ ===== */
.mobile-menu {
    display: none;
    position: relative;
}

.burger-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 44px;
    height: 44px;
    background: var(--btn-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    padding: 8px;
}

.burger-btn span {
    width: 100%;
    height: 3px;
    background: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s ease;
}

body.dark-theme .burger-btn span {
    background: white;
}

.burger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.burger-btn.active span:nth-child(2) {
    opacity: 0;
}

.burger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.burger-dropdown {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background-color: var(--modal-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    min-width: 220px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.burger-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 16px;
    font-weight: normal;
    cursor: pointer;
    text-decoration: none;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

.burger-item:last-child {
    border-bottom: none;
}

.burger-item:hover {
    background-color: var(--btn-primary-hover);
    color: var(--text-color);
}

.burger-icon {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (min-width: 1025px) {
    .types-container {
        grid-template-columns: repeat(8, 1fr);
    }

    .container {
        margin: 25px auto;
    }

    .contact-btn,
    .auth-btn,
    .theme-toggle-btn,
    .install-btn {
        width: 40px;
        height: 40px;
    }

    .contact-icon,
    .auth-icon,
    .theme-icon,
    .install-icon {
        font-size: 20px;
    }

    .editBtn,
    .deleteBtn {
        width: 36px;
        height: 36px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .types-container {
        grid-template-columns: repeat(5, 1fr);
    }

    .container {
        max-width: 95%;
        margin: 20px auto;
    }

    .table {
        font-size: 14px;
    }

    th,
    td {
        padding: 6px 4px;
        font-size: 13px;
    }

    .contact-btn,
    .auth-btn,
    .theme-toggle-btn,
    .install-btn {
        width: 38px;
        height: 38px;
    }

    .contact-icon,
    .auth-icon,
    .theme-icon,
    .install-icon {
        font-size: 19px;
    }

    .editBtn,
    .deleteBtn {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 15px 10px;
    }

    .contact-buttons-left,
    .action-buttons-right {
        display: none;
    }

    .mobile-menu {
        display: block;
    }

    .header-container {
        padding: 0 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .title-wrapper {
        flex: 1;
        text-align: center;
    }

    .allAboutProducts,
    .search-container,
    .table,
    .textWarn {
        width: 98%;
        margin-left: auto;
        margin-right: auto;
    }

    .action-buttons {
        gap: 4px;
    }

    .editBtn,
    .deleteBtn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .edit-icon,
    .delete-icon {
        font-size: 12px;
    }

    .types-container {
        grid-template-columns: repeat(3, 1fr);
    }

    .types-control button {
        padding: 8px 4px;
        font-size: 12px;
        height: 36px;
    }

    #inputName,
    #inputValue,
    #inputUnit {
        height: 36px;
        font-size: 13px;
    }

    .calculator-btn,
    .sortBtn,
    .addToTableBtn,
    .excelBtn,
    .clearTable {
        height: 36px;
        font-size: 14px;
    }

    .table {
        font-size: 12px;
    }

    th,
    td {
        padding: 4px 3px;
        font-size: 11px;
    }

    .t-delete-header::after {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px 10px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .contact-btn,
    .auth-btn,
    .theme-toggle-btn,
    .install-btn {
        width: 34px;
        height: 34px;
    }

    .contact-icon,
    .auth-icon,
    .theme-icon,
    .install-icon {
        font-size: 17px;
    }

    .types-control button {
        height: 36px;
    }

    #inputName,
    #inputValue,
    #inputUnit {
        height: 36px;
    }

    .calculator-btn,
    .sortBtn,
    .addToTableBtn,
    .excelBtn,
    .clearTable {
        height: 36px;
    }
}

@media (max-width: 375px) {
    h1 {
        font-size: 1.2rem;
    }

    .contact-btn,
    .auth-btn,
    .theme-toggle-btn,
    .install-btn {
        width: 32px;
        height: 32px;
    }

    .contact-icon,
    .auth-icon,
    .theme-icon,
    .install-icon {
        font-size: 16px;
    }

    .types-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .type,
    .selected-type {
        font-size: 9px;
        padding: 5px 2px;
        min-height: 26px;
    }

    #inputName,
    #inputValue,
    #inputUnit {
        height: 34px;
    }

    .calculator-btn,
    .sortBtn,
    .addToTableBtn,
    .excelBtn,
    .clearTable {
        height: 34px;
    }

    .calc-btn {
        height: 34px;
        font-size: 13px;
    }

    .calculator-backspace .calc-btn {
        height: 34px;
    }

    #calculatorDisplay {
        height: 34px;
    }
}

@media (orientation: landscape) and (max-height: 480px) {

    #inputName,
    #inputValue,
    #inputUnit {
        height: 36px !important;
        line-height: normal !important;
    }

    .calculator-btn,
    .sortBtn,
    .addToTableBtn,
    .excelBtn,
    .clearTable {
        height: 36px !important;
    }

    .types-control button {
        height: 30px !important;
    }

    .calc-btn {
        height: 36px !important;
    }

    .calculator-backspace .calc-btn {
        height: 36px !important;
    }
}

/* ===== ПРОИЗВОДИТЕЛЬНОСТЬ ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== iOS ===== */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }

    .search-input,
    #inputName,
    #inputValue {
        font-size: 16px;
    }

    input,
    textarea,
    select {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
}

textarea.login-input {
    height: auto;
    min-height: 100px;
    resize: vertical;
    padding: 10px 15px;
    font-family: inherit;
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
}

/* ===== МОДАЛЬНОЕ ОКНО ОБНОВЛЕНИЯ ВЕРСИИ ===== */
.version-update-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.version-update-modal .modal-content {
    background: var(--modal-bg);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    text-align: center;
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.version-update-modal .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.version-update-modal .btn {
    flex: 1;
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    background: var(--btn-primary);
    color: var(--text-color);
}

.version-update-modal .btn:hover {
    background: var(--btn-primary-hover);
}

.version-update-modal #update-later {
    background: #6c757d;
    color: white;
}

.version-update-modal #update-later:hover {
    background: #5a6268;
}