:root {
    --primary-color: #5e35b1;
    --primary-light: #7e57c2;
    --primary-dark: #4527a0;
    --secondary-color: #ff9800;
    --secondary-light: #ffb74d;
    --secondary-dark: #f57c00;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --text-color: #333;
    --text-light: #757575;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 30px 0;
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Main Content */
main {
    margin-bottom: 60px;
}

/* Instructions */
.instructions {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.instructions h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions ol {
    padding-left: 25px;
}

.instructions li {
    margin-bottom: 8px;
}

/* Filter and Search */
.filter-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.search-input {
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    font-size: 1rem;
    outline: none;
    width: 100%;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(94, 53, 177, 0.2);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-btn.active, .filter-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.product-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.product-image {
    height: 200px;
    width: 100%;
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
}

.reserved-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: var(--primary-color);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-color);
}

.product-category {
    display: inline-block;
    background-color: rgba(94, 53, 177, 0.1);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

/* Price styling removed as requested */

.product-gifter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    color: var(--success-color);
    font-weight: 500;
}

.product-description {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 15px;
    line-height: 1.4;
}

.gift-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
}

.gift-btn:hover {
    background-color: var(--primary-dark);
}

.gift-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    transition: var(--transition);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: var(--text-light);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text-color);
}

.modal h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

#modal-product-details {
    display: flex;
    margin-bottom: 20px;
}

.modal-product-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
}

.modal-product-info {
    margin-left: 15px;
    flex-grow: 1;
}

.modal-product-name {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

/* Modal product price removed as requested */

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(94, 53, 177, 0.1);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

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

.btn-secondary:hover {
    background-color: var(--secondary-dark);
}

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

.btn-danger:hover {
    background-color: #d32f2f;
}

/* Success Modal */
.modal-content.success {
    text-align: center;
}

.success-icon {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 20px;
}

/* Loading Spinner */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    width: 100%;
}

.spinner {
    border: 4px solid rgba(94, 53, 177, 0.2);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer Styles */
footer {
    background-color: var(--primary-color);
    color: white;
    padding: 20px 0;
    text-align: center;
}

/* Admin Page Specific Styles */
.admin-page header {
    background-color: var(--secondary-color);
}

.admin-controls {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
    align-items: flex-start;
}

.admin-btn-group {
    display: flex;
    gap: 15px;
}

.admin-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: stretch; /* Ensure all items stretch to match the tallest */
}

.stat-card {
    background-color: var(--card-bg);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 150px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px; /* Fixed height for all cards */
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 8px;
    height: 2.5em; /* Fixed height for title to ensure alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.stat-card p {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--primary-color);
}

.admin-search {
    margin-bottom: 20px;
}

.table-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: #f5f5f5;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* Limit width to prevent overflow */
    height: 66px; /* Consistent height for all rows */
    vertical-align: middle;
}

th {
    font-weight: 600;
    color: var(--text-color);
    position: relative;
}

/* Ensure consistent row height */
#products-table tr {
    height: 66px;
}

/* Make name and category columns flexible */
table td:nth-child(2), 
table th:nth-child(2),
table td:nth-child(3),
table th:nth-child(3) {
    white-space: normal;
}

/* Column width settings for better table layout */
/* Image column */
table th:first-child,
table td:first-child {
    width: 70px;
    min-width: 70px;
    max-width: 70px;
}

/* Name column - allow it to grow */
table th:nth-child(2),
table td:nth-child(2) {
    min-width: 150px;
    max-width: 250px;
}

/* Category column */
table th:nth-child(3),
table td:nth-child(3) {
    min-width: 100px;
    max-width: 150px;
}

/* Status column */
table th:nth-child(4),
table td:nth-child(4) {
    width: 100px;
    min-width: 100px;
}

/* Gift by column */
table th:nth-child(5),
table td:nth-child(5) {
    min-width: 120px;
    max-width: 150px;
}

/* Actions column */
table th:last-child,
table td:last-child {
    width: 120px;
    min-width: 120px;
    text-align: center;
    vertical-align: middle; /* Ensures vertical alignment */
    padding: 0 15px; /* Consistent padding */
}

td {
    color: var(--text-light);
}

.table-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

.product-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-block;
}

.status-available {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.status-reserved {
    background-color: rgba(94, 53, 177, 0.1);
    color: var(--primary-color);
}

.action-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    white-space: nowrap;
    height: 66px; /* Match cell height */
    align-items: center; /* Center buttons vertically */
}

.edit-btn, .delete-btn {
    padding: 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-weight: 500;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.edit-btn:hover {
    background-color: var(--primary-dark);
}

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

.delete-btn:hover {
    background-color: #d32f2f;
}

.delete-btn i {
    margin-right: 0;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

/* Button icon styling */
.edit-btn i, .delete-btn i {
    font-size: 1rem;
}

/* Make sure the action column stays properly aligned on all devices */
@media (max-width: 992px) {
    .action-btns {
        gap: 8px;
    }
    
    .edit-btn, .delete-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
}

/* Add hover effect to table rows */
#products-table tbody tr {
    transition: background-color 0.2s ease;
}

#products-table tbody tr:hover {
    background-color: rgba(94, 53, 177, 0.05);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 20px;
}

.delete-warning {
    font-weight: 600;
    margin: 15px 0;
    color: var(--danger-color);
}

.admin-page footer {
    background-color: var(--secondary-color);
}

/* Específico para o card "Total de Produtos" */
#total-products {
    margin-top: auto; /* Push to bottom */
}

/* Garantir que todos os títulos dos cards estatísticos fiquem alinhados */
.stat-card h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}

/* Estilo para aviso de modo offline */
.offline-warning {
    background-color: var(--danger-color);
    color: white;
    text-align: center;
    padding: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-in-out;
}

.offline-warning i {
    margin-right: 8px;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Responsive Styles */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 15px;
    }
    
    .admin-controls {
        flex-direction: column;
    }
    .admin-stats {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }
    
    .stat-card {
        flex-basis: calc(33% - 10px);
        padding: 10px;
        min-width: 100px;
        height: 90px; /* Slightly smaller height on tablets */
    }
    
    .stat-card h3 {
        font-size: 0.85rem;
    }
      .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Better scroll on iOS */
        margin: 0 -15px; /* Extend beyond container on mobile */
        padding: 0 15px; /* Add padding back */
        width: calc(100% + 30px);
    }
    
    table {
        min-width: 750px;
    }
    
    thead {
        position: sticky;
        top: 0;
        z-index: 1;
        background-color: #f5f5f5;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
    }
    
    .filter-container {
        gap: 10px;
    }
    
    .filter-btn {
        padding: 6px 15px;
        font-size: 0.85rem;
    }
    
    .instructions {
        padding: 15px;
    }
    
    .instructions h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px 0;
        margin-bottom: 25px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header .subtitle {
        font-size: 1rem;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-card {
        max-width: 100%;
    }
    
    .product-image {
        height: 180px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        margin: 15% auto;
        padding: 15px;
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-name {
        font-size: 1.1rem;
    }
    
    .filter-buttons {
        justify-content: center;
    }
      .admin-btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .admin-btn-group .btn {
        width: 100%;
        justify-content: center;
    }
      /* Improved stats cards for very small screens */
    .admin-stats {
        flex-direction: column;
    }
    
    .stat-card {
        width: 100%;
        flex-basis: 100%;
        display: flex;
        flex-direction: row; /* Change to horizontal layout on mobile */
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 12px 15px;
        height: auto; /* Reset height for mobile */
    }
    
    .stat-card h3 {
        margin-bottom: 0;
        font-size: 1rem;
        height: auto; /* Reset fixed height */
        justify-content: flex-start; /* Left align on mobile */
        flex: 1;
    }
    
    .stat-card p {
        font-size: 1.5rem;
    }
}
