/* admin.css */

/* --- Base & Typography --- */
body {
    font-family: 'Inter', sans-serif;
}

/* --- Modals --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
    justify-content: center;
    align-items: center;
    padding: 20px; /* Add padding for smaller screens */
}

.modal-content {
    background-color: #fefefe;
    margin: auto; 
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 90%; 
    max-width: 600px; 
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translateY(-50px);
    opacity: 0;
}

/* Show effect */
.modal[style*="display: flex"] .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-title {
    font-size: 1.75rem; /* text-3xl */
    font-weight: 700; /* font-bold */
    color: #1f2937; /* text-gray-800 */
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb; /* border-gray-200 */
    padding-bottom: 10px;
}

.modal-form label {
    display: block;
    font-weight: 500; /* font-medium */
    color: #4b5563; /* text-gray-700 */
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.modal-form input[type="text"],
.modal-form input[type="number"],
.modal-form input[type="url"],
.modal-form textarea,
.modal-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db; /* border-gray-300 */
    border-radius: 6px;
    margin-bottom: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-form input:focus,
.modal-form textarea:focus,
.modal-form select:focus {
    border-color: #4f46e5; /* indigo-600 */
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    outline: none;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    color: white;
    background-color: #4f46e5; /* indigo-600 */
    transition: background-color 0.2s;
    cursor: pointer;
    border: none;
}

.btn-primary:hover {
    background-color: #4338ca; /* indigo-700 */
}

.btn-cancel {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    background-color: #e5e7eb; /* gray-200 */
    color: #374151; /* gray-700 */
    transition: background-color 0.2s;
    cursor: pointer;
    border: none;
}

.btn-cancel:hover {
    background-color: #d1d5db; /* gray-300 */
}

/* --- Product Grid & Card --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: transform 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.product-image-container {
    height: 150px; 
    overflow: hidden;
    position: relative;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-info {
    padding: 15px;
}

.product-category {
    font-size: 0.75rem; /* text-xs */
    color: #6b7280; /* text-gray-500 */
    margin-bottom: 4px;
}

.product-name {
    font-size: 1.125rem; /* text-lg */
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.product-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.btn-action {
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.875rem; /* text-sm */
    font-weight: 500;
    transition: background-color 0.2s;
    border: 1px solid #d1d5db;
    cursor: pointer;
}

.btn-edit {
    color: #2563eb; /* blue-600 */
    background-color: #eff6ff; /* blue-50 */
}

.btn-edit:hover {
    background-color: #dbeafe; /* blue-100 */
}

.btn-delete {
    color: #ef4444; /* red-500 */
    background-color: #fee2e2; /* red-100 */
}

.btn-delete:hover {
    background-color: #fecaca; /* red-200 */
}

/* Specific button for 'เพิ่มสินค้าใหม่' */
.btn-add-product {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: white;
    background-color: #4f46e5; /* indigo-600 */
    transition: background-color 0.2s;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
}

.btn-add-product:hover {
    background-color: #4338ca; /* indigo-700 */
}

/* --- Toast Notification --- */
.toast-notification {
    visibility: hidden; 
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 1001;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    font-size: 17px;
    box-shadow: 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.toast-notification.show {
    visibility: visible;
    -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
    from {bottom: 0; opacity: 0;} 
    to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
    from {bottom: 0; opacity: 0;}
    to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
    from {bottom: 30px; opacity: 1;} 
    to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
    from {bottom: 30px; opacity: 1;}
    to {bottom: 0; opacity: 0;}
}

/* --- Category Management List --- */
.category-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.1s;
}

.category-list-item:hover {
    background-color: #f9fafb;
}

.category-list-item:last-child {
    border-bottom: none;
}

.category-image-preview {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

/* --- Flash Sale List Admin --- */
.flash-sale-list-admin {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flash-sale-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #fff;
    border: 1px solid #fca5a5; /* red-300 */
    border-radius: 6px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Ensure body doesn't scroll when a modal is open */
.modal-open {
    overflow: hidden;
}

/* Additional utility for small screens */
@media (max-width: 640px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}