/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8B4513;
    --primary-dark: #654321;
    --secondary-color: #D2691E;
    --accent-color: #FF8C00;
    --success-color: #4CAF50;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #F5F5F5;
    --white: #FFFFFF;
    --border-color: #DDD;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

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

/* Header */
.header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-buttons {
    display: flex;
    gap: 0.5rem;
}

.auth-buttons button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info span {
    font-size: 0.9rem;
    color: var(--text-dark);
}

.user-info button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.cart-button {
    position: relative;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s;
}

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

.cart-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.cart-count {
    background-color: var(--accent-color);
    color: var(--white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
}

.cart-count.hidden {
    display: none !important;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 3rem 0;
    text-align: center;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.95;
}

/* Products Section */
.products-section {
    padding: 3rem 0;
    min-height: 400px;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
    text-align: center;
}

.loading {
    text-align: center;
    padding: 3rem 0;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

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

.product-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.product-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.product-icon {
    font-size: 2rem;
}

.product-title {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
}

.bundle-badge {
    background-color: #007AFF;
    color: var(--white);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.product-description {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.product-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.product-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success-color);
}

.product-stock {
    font-size: 0.875rem;
    color: var(--text-light);
}

.stock-loading {
    font-size: 0.75rem;
}

.stock-low {
    color: var(--accent-color);
    font-weight: 600;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-light);
    padding: 0.5rem;
    border-radius: 8px;
}

.quantity-btn {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.quantity-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quantity-display {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.add-to-cart-btn {
    flex: 1;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.add-to-cart-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.no-products {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-light);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: var(--white);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: var(--bg-light);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.modal-footer-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-footer-buttons {
    display: flex;
    gap: 1rem;
}

/* Auth */
.auth-switch {
    text-align: center;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

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

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    border: 2px solid #f5c6cb;
    font-weight: 600;
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Cart */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-light);
    border-radius: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.cart-item-details {
    font-size: 0.875rem;
    color: var(--text-light);
}

.cart-item-remove {
    background-color: transparent;
    color: #DC3545;
    border: 1px solid #DC3545;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.cart-item-remove:hover {
    background-color: #DC3545;
    color: var(--white);
}

.empty-cart {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-light);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.total-amount {
    color: var(--success-color);
    font-size: 1.5rem;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

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

/* Success Message */
.success-message {
    text-align: center;
    padding: 2rem 0;
}

.success-icon {
    width: 80px;
    height: 80px;
    background-color: var(--success-color);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin: 0 auto 1rem;
}

.success-message p {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.success-detail {
    color: var(--text-light);
    font-size: 1rem;
}

/* Profile */
.profile-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.profile-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.success-message-inline {
    background-color: #d4edda;
    color: #155724;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    border: 2px solid #c3e6cb;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h2 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .modal-content {
        width: 95%;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-footer-messages {
        width: 100%;
    }

    .modal-footer-buttons {
        width: 100%;
        flex-direction: column;
    }

    .modal-footer-buttons button {
        width: 100%;
    }
}

/* ========================================
   Orders History Modal
   ======================================== */
.modal-large .modal-content {
    max-width: 800px;
}

.order-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.order-info h3 {
    font-size: 1.1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.order-date {
    font-size: 0.875rem;
    color: var(--text-light);
}

.order-status {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.status-new {
    background: #e3f2fd;
    color: #1976d2;
}

.status-confirmed {
    background: #e8f5e9;
    color: #388e3c;
}

.status-preparing {
    background: #fff3e0;
    color: #f57c00;
}

.status-delivered {
    background: #f5f5f5;
    color: #616161;
}

.status-cancelled {
    background: #ffebee;
    color: #d32f2f;
}

.order-items {
    margin: 1rem 0;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.order-item-name {
    color: var(--text-dark);
}

.order-item-quantity {
    color: var(--text-light);
    margin-left: 0.5rem;
}

.order-item-price {
    font-weight: 600;
    color: var(--primary);
}

.order-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    font-size: 1.1rem;
    font-weight: 700;
}

.order-total-label {
    color: var(--text-dark);
}

.order-total-amount {
    color: var(--primary);
    font-size: 1.25rem;
}

.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--text-light);
}

/* ========================================
   Message Section
   ======================================== */
.message-section {
    padding: 1.5rem 0;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-left: 4px solid var(--primary);
}

.message-content {
    padding: 0 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-dark);
    white-space: pre-line;
    text-align: center;
    font-weight: 500;
}
