/* Admin Panel Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 100%;
}

.login-box h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.login-box p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

/* Admin Panel */
.admin-panel {
    display: none;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-header {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-header h1 {
    color: #333;
    font-size: 24px;
}

.btn-logout {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.tabs {
    background: white;
    padding: 0;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab-buttons {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 16px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #fff;
    color: #667eea;
}

.tab-btn.active {
    background: #fff;
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* Dashboard */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.stat-card h3 {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-card .number {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-card .label {
    font-size: 12px;
    opacity: 0.8;
}

/* Product Management */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-add {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.product-form {
    display: none;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.product-form.active {
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.image-upload-area {
    border: 3px dashed #667eea;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.image-upload-area:hover {
    border-color: #764ba2;
    background: #f8f9ff;
}

.image-upload-area input[type="file"] {
    display: none;
}

.image-preview {
    margin-top: 15px;
    max-width: 200px;
    max-height: 200px;
    display: none;
    margin-left: auto;
    margin-right: auto;
}

.image-preview img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

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

.btn-save {
    padding: 12px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    position: relative;
    transition: background 0.3s ease;
}

.btn-save:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-save.loading {
    padding-right: 45px;
}

.btn-save .btn-spinner {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-save.loading .btn-spinner {
    display: block;
}

.btn-cancel {
    padding: 12px 30px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    min-width: 600px; /* Ensure table has minimum width */
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.product-image-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-edit, .btn-delete, .btn-view {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

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

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-view {
    background: #17a2b8;
    color: white;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* Success Message */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    border-left: 4px solid #28a745;
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.status-paid {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-pending {
    background: #fff3cd;
    color: #856404;
}

/* Order Modal */
.order-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.order-modal {
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.order-modal-header {
    padding: 25px 30px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.order-modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 32px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.3s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.order-modal-content {
    padding: 30px;
}

.order-info-section {
    margin-bottom: 30px;
}

.order-info-section h3 {
    color: #667eea;
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.order-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 12px;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
}

.info-value {
    font-size: 14px;
    color: #333;
}

.info-value a {
    color: #667eea;
    text-decoration: none;
}

.info-value a:hover {
    text-decoration: underline;
}

.info-value code {
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.order-items-list {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.order-item {
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.order-item:last-child {
    border-bottom: none;
}

.order-modal-footer {
    padding: 20px 30px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
}

.order-modal-footer a {
    text-decoration: none;
}

/* Table Container for Mobile Scroll */
#productsTable,
#customersTable,
#ordersTable,
#recentOrders {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Responsive */
@media (max-width: 768px) {
    .tab-buttons {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        white-space: nowrap;
        font-size: 14px;
        padding: 14px 16px;
    }

    .tab-content {
        padding: 15px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 11px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        white-space: nowrap; /* Prevent text wrapping in cells */
    }

    .action-buttons {
        flex-direction: row; /* Keep horizontal on mobile for table */
        gap: 4px;
    }

    .btn-edit, .btn-delete, .btn-view {
        padding: 4px 8px;
        font-size: 11px;
    }

    .admin-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }

    .admin-header h1 {
        font-size: 20px;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-card .number {
        font-size: 28px;
    }

    .order-modal {
        max-height: 95vh;
    }

    .order-info-grid {
        grid-template-columns: 1fr;
    }

    .order-modal-footer {
        flex-direction: column;
    }

    .product-image-thumb {
        width: 40px;
        height: 40px;
    }

    /* Add scroll indicator hint */
    #productsTable::after,
    #customersTable::after,
    #ordersTable::after,
    #recentOrders::after {
        content: '← Scroll to see more →';
        display: block;
        text-align: center;
        padding: 10px;
        font-size: 11px;
        color: #999;
        background: linear-gradient(90deg, transparent, #f8f9fa 20%, #f8f9fa 80%, transparent);
    }
}
