/* ——— ОСНОВНОЙ СТИЛЬ ——— */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #333;
}

.page-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sidebar h3 {
    text-align: center;
    margin: 0;
}

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

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.collection-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.collection-toolbar .search-input {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}
.collection-toolbar select {
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    background: #1c1c1e;
    color: #f5f5f7;
    font-size: 14px;
    cursor: pointer;
}

.search-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: none;
    outline: none;
    font-size: 14px;
    box-sizing: border-box;
}

.suggestions {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.suggestions li {
    padding: 8px 10px;
    background: #ffffff;
    color: #000;
    cursor: pointer;
    margin-bottom: 6px;
    border-radius: 5px;
    font-size: 14px;
}

.suggestions li:hover {
    background: #e6e6e6;
}

.sidebar a {
    color: #ecf0f1;
    text-decoration: none;
    display: block;
    padding: 6px 0;
}

.sidebar a:hover {
    color: #3498db;
    padding-left: 10px;
}

.sidebar-footer {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding-top: 15px;
    padding-bottom: 30px;
    border-top: 1px solid rgba(255,255,255,0.15);
    background: #2c3e50;
    z-index: 1;
    text-align: center;
}

.user-email {
    display: block;
    font-size: 14px;
    color: #ecf0f1;
    margin-bottom: 8px;
    word-break: break-all;
    font-weight: 500;
}

.admin-link {
    display: block;
    color: #ffd60a;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    padding: 6px 0;
    background: rgba(255,214,10,0.08);
    border-radius: 6px;
}
.admin-link:hover {
    color: #fff;
    background: rgba(255,214,10,0.2);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

.main-scrollable-content {
    flex-grow: 1;
    padding: 24px 32px;
    overflow-y: auto;
    height: 100%;
}

form {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
}

form button[type="submit"] {
    grid-column: 1/3;
    padding: 12px;
    background: #28a745;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 15px;
    border-radius: 6px;
}

form button[type="submit"]:hover {
    background: #218838;
}

.country-group {
    margin-top: 25px;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
}

.banknotes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.banknote-card {
    background: #f7f7f7;
    border: 2px solid #d0d0d0;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: 0.2s ease;
}

.banknote-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.banknote-images-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.image-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-label {
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.image-box img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    background: transparent;
    cursor: pointer;
}

/* ——— МОДАЛЬНОЕ ОКНО (фото) ——— */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.modal-image-wrapper {
    position: relative;
    width: 90%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.2s ease-out;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.close-button {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 40px;
    cursor: pointer;
    color: white;
    z-index: 10;
    background: none;
    border: none;
}

.modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
}

.prev-arrow { left: 20px; }
.next-arrow { right: 20px; }

.modal-note {
    color: #fff;
    margin-top: 20px;
    max-width: 80%;
    text-align: center;
    font-size: 1.1em;
    opacity: 0.9;
    line-height: 1.4;
}

.download-button {
    margin-top: 10px;
    padding: 8px 20px;
    background: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
}

.download-button:hover {
    background: #2980b9;
}

/* ——— МОДАЛЬНОЕ ОКНО (редактирование) ——— */
.edit-modal {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.edit-modal-content {
    background: #fff;
    padding: 25px;
    width: 400px;
    border-radius: 10px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.edit-modal-content input,
.edit-modal-content textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 6px;
    box-sizing: border-box;
}

.edit-modal-content hr {
    margin: 15px 0;
    border: none;
    border-top: 1px solid #ddd;
}

.save-edit-btn {
    width: 100%;
    padding: 10px;
    background: #198754;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 15px;
    border-radius: 6px;
}

.save-edit-btn:hover {
    background: #157347;
}

/* ——— СТАТИСТИКА В САЙДБАРЕ ——— */
.country-stats {
    background: #ffffff;
    color: #000;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.4;
}

.country-stats p {
    margin: 4px 0;
}

/* ——— ФОРМА: блок загрузки фото ——— */
.upload-photo-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.upload-photo-box {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-label {
    margin-bottom: 6px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

.edit-file-box {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ——— КНОПКИ ——— */
.calc-price-btn {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #3498db;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.calc-price-btn:hover {
    background: #2980b9;
}

.total-price-result {
    margin-top: 8px;
    font-weight: bold;
    text-align: center;
}

.add-banknote-btn {
    width: 100%;
    margin: 10px 0 15px;
    padding: 10px;
    background: #28a745;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.add-banknote-btn:hover {
    background: #218838;
}

.edit-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.edit-buttons button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.edit-buttons .edit-btn {
    background: #ffc107;
    color: #000;
}

.edit-buttons .edit-btn:hover {
    background: #e0a800;
}

.edit-buttons .delete-btn {
    background: #dc3545;
    color: #fff;
}

.edit-buttons .delete-btn:hover {
    background: #c82333;
}

/* ——— КНОПКА ОТКРЫТИЯ АРХИВА (мобильная) ——— */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 10px;
    touch-action: manipulation;
}

/* ——— ЗАТЕМНЕНИЕ САЙДБАРА ——— */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
}

.sidebar-overlay.show {
    display: block;
}

/* ——— МОБИЛЬНАЯ ШАПКА (скрыта на десктопе) ——— */
.mobile-header {
    display: none;
}

/* =========================
   СТРАНИЦЫ АВТОРИЗАЦИИ
   ========================= */
.auth-page {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.auth-container {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.auth-container h1 {
    text-align: center;
    margin: 0 0 4px;
    font-size: 28px;
    color: #2c3e50;
}

.auth-subtitle {
    text-align: center;
    color: #666;
    margin: 0 0 24px;
    font-size: 15px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.auth-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
}

.auth-form input:focus {
    border-color: #3498db;
    outline: none;
}

.auth-form button {
    padding: 12px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 8px;
}

.auth-form button:hover {
    background: #34495e;
}

.auth-error {
    color: #dc3545;
    font-size: 14px;
    margin: 0;
    text-align: center;
}

.auth-success {
    color: #28a745;
    font-size: 14px;
    margin: 0;
    text-align: center;
}

.auth-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.auth-links a {
    color: #3498db;
    text-decoration: none;
    font-size: 14px;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* =========================
   МОБИЛЬНАЯ ВЕРСИЯ (до 768px)
   ========================= */
@media (max-width: 768px) {
    /* шапка */
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 4px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 3500;
        background: #2c3e50;
        color: #fff;
        padding: 8px 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    .sidebar-toggle {
        display: block;
    }

    .mobile-user-email {
        flex: 1;
        font-size: 14px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 4px;
    }

    .mobile-admin-link {
        color: #ffd60a;
        text-decoration: none;
        font-size: 18px;
        padding: 6px 8px;
        border-radius: 6px;
    }
    .mobile-admin-link:active {
        background: rgba(255,214,10,0.2);
    }

    .mobile-logout-btn {
        background: none;
        border: none;
        color: #fff;
        font-size: 18px;
        padding: 6px 8px;
        cursor: pointer;
        border-radius: 6px;
        touch-action: manipulation;
    }
    .mobile-logout-btn:active {
        background: rgba(255,255,255,0.2);
    }

    /* контейнер — без overflow hidden, чтоб скроллилось */
    .page-container {
        height: auto;
        overflow: visible;
        padding-top: 50px;
    }

    /* сайдбар — справа */
    .sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        left: auto;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 2500;
        transition: right 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        right: 0;
        left: auto;
    }

    .sidebar-close-btn {
        display: block;
    }

    /* скрыть футер сайдбара (email/админ/выход — в шапке) */
    .sidebar-footer {
        display: none;
    }

    /* контент — скролл */
    .main-scrollable-content {
        padding: 16px;
        height: auto;
        overflow: visible;
    }

    body {
        font-size: 16px;
        line-height: 1.5;
    }

    h1 { font-size: 22px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }

    .sidebar h3 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .sidebar a {
        font-size: 16px;
        padding: 10px 0;
    }

    .country-stats {
        font-size: 15px;
    }

    button,
    .add-banknote-btn,
    .calc-price-btn {
        padding: 14px;
        font-size: 16px;
        border-radius: 10px;
    }

    input,
    textarea {
        font-size: 16px;
        padding: 12px;
        border-radius: 10px;
        box-sizing: border-box;
    }

    label {
        font-size: 14px;
        margin-bottom: 4px;
    }

    form {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    form button[type="submit"] {
        grid-column: 1;
    }

    .upload-photo-row {
        flex-direction: column;
        gap: 12px;
    }

    .banknote-card {
        padding: 18px;
        border-radius: 16px;
    }

    .banknote-card p {
        margin: 6px 0;
        font-size: 15px;
    }

    .image-box img {
        max-height: 300px;
    }

    .image-label {
        font-size: 15px;
    }

    .edit-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .edit-buttons button {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }

    .modal-note {
        font-size: 16px;
        padding: 0 10px;
    }

    .modal-arrow {
        padding: 14px;
        font-size: 26px;
    }

    .close-button {
        font-size: 44px;
        right: 15px;
        top: 15px;
    }

    .edit-modal-content {
        width: 92%;
        max-width: 500px;
        padding: 20px;
    }

    .collection-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .collection-toolbar .search-input {
        min-width: auto;
    }
    .collection-toolbar select {
        font-size: 16px;
        padding: 10px;
    }
    .search-input {
        font-size: 16px;
        padding: 10px;
    }

    .suggestions li {
        padding: 12px 14px;
        font-size: 16px;
    }

    .auth-container {
        padding: 24px;
    }
}
