body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
}

header {
    background-color: #343a40;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 1.8em;
}

nav button {
    background: #ff7e00;
    color: white;
    border: none;
    padding: 10px 15px;
    margin-left: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

nav button:hover {
    background-color: #e66f00;
}

main {
    padding: 20px;
}

.hidden-view, .hidden {
    /* Використовуємо !important, щоб JavaScript точно керував відображенням */
    display: none !important;
}

/* -------------------------------------------------------------------------- */
/* I. СТИЛІ ФОРМ ТА АДМІН-ПАНЕЛІ */
/* -------------------------------------------------------------------------- */

.admin-form-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

#login-form, #product-form {
    display: grid;
    gap: 10px;
    max-width: 500px;
    margin-top: 15px;
}

#product-form {
    max-width: 700px;
    grid-template-columns: 1fr;
}

#product-form input[type="text"],
#product-form input[type="number"],
#product-form textarea,
#product-form select,
#login-form input[type="text"],
#login-form input[type="password"] {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.form-actions button {
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#submit-btn {
    background-color: #28a745;
    color: white;
}

#cancel-edit {
    background-color: #6c757d;
    color: white;
}

.error-message {
    color: #dc3545;
    font-weight: bold;
    margin-top: 5px;
}

/* -------------------------------------------------------------------------- */
/* II. СТИЛІ ДЛЯ КАРТОК ТА КАТАЛОГУ */
/* -------------------------------------------------------------------------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.product-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 15px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.product-card.admin {
    cursor: default;
}

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 10px;
}

.product-card h3 {
    font-size: 1.2em;
    margin: 5px 0;
}

.product-card .price {
    font-size: 1.4em;
    color: #ff7e00;
    font-weight: bold;
    margin: 10px 0;
}

.product-card .actions button {
    padding: 8px 12px;
    margin-top: 5px;
    margin-right: 5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.product-card .edit-btn { background-color: #007bff; color: white; }
.product-card .delete-btn { background-color: #dc3545; color: white; }

.product-card .buy-button-card {
    background: #ff7e00;
    color: white;
    padding: 8px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    margin-top: 10px;
}

/* -------------------------------------------------------------------------- */
/* III. СТИЛІ ДЛЯ ПАНЕЛІ КОНТРОЛЮ (Сортування та Фільтри) */
/* -------------------------------------------------------------------------- */

#controls-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#category-filter .filter-btn {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#category-filter .filter-btn.active,
#category-filter .filter-btn:hover {
    background-color: #ff7e00;
    color: white;
    border-color: #ff7e00;
}

#sort-controls label {
    font-weight: bold;
    margin-right: 10px;
    color: #343a40;
}

#sort-select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ced4da;
    cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/* IV. СТИЛІ ДЛЯ ДЕТАЛЬНОЇ СТОРІНКИ ТОВАРУ (Single Product View) */
/* -------------------------------------------------------------------------- */

#single-product-view {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

#product-details-content {
    display: flex;
    gap: 40px;
    margin-top: 20px;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

#product-image-gallery {
    flex: 1;
    min-width: 400px;
}

#product-info {
    flex: 1.5;
}

#main-product-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#product-info h2 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #333;
}

#product-info .details-price {
    font-size: 1.8em;
    color: #ff7e00;
    font-weight: bold;
    margin-bottom: 20px;
}

#product-info p {
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
}

.buy-button {
    background: #28a745;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1em;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 20px;
}

.buy-button:hover {
    background-color: #218838;
}

.back-btn {
    background: none;
    color: #007bff;
    border: none;
    padding: 10px 0;
    cursor: pointer;
    font-size: 1em;
    text-decoration: underline;
    margin-bottom: 15px;
}


/* -------------------------------------------------------------------------- */
/* V. СТИЛІ ДЛЯ СПЛИВАЮЧИХ ПОВІДОМЛЕНЬ (ТОСТЕРІВ) */
/* -------------------------------------------------------------------------- */

#message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 300px;
    max-width: 90%;
}

.toast-message {
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 500;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    color: #ffffff;

    /* Анімація входу/виходу */
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-message.success {
    background-color: #4CAF50; /* Приємний зелений */
    border-left: 5px solid #388E3C;
}

.toast-message.error {
    background-color: #F44336; /* Червоний */
    border-left: 5px solid #D32F2F;
}

.toast-message.info {
    background-color: #2196F3; /* Синій */
    border-left: 5px solid #1976D2;
}