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

:root {
    --primary-color: #2c5aa0;
    --primary-dark: #1e3d72;
    --secondary-color: #f8f9fa;
    --accent-color: #ff6b35;
    --text-dark: #2d3748;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --error-color: #f56565;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: #f8fafc;
}

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

/* Icons */
.icon-user::before { content: "👤"; }
.icon-lock::before { content: "🔒"; }
.icon-login::before { content: "→"; }
.icon-warning::before { content: "⚠️"; }
.icon-help::before { content: "❓"; }
.icon-search::before { content: "🔍"; }
.icon-logout::before { content: "🚪"; }
.icon-products::before { content: "📦"; }
.icon-update::before { content: "🕒"; }
.icon-image::before { content: "🖼️"; }
.icon-sku::before { content: "🏷️"; }
.icon-category::before { content: "📁"; }
.icon-no-products::before { content: "😔"; font-size: 3rem; }
.icon-first::before { content: "⏮"; }
.icon-prev::before { content: "◀"; }
.icon-next::before { content: "▶"; }
.icon-last::before { content: "⏭"; }
.icon-details::before { content: "👁️"; }
.icon-filter::before { content: "🔍"; }

/* Login Page */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-form {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.site-logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 1.5rem;
}

.logo h1 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
    font-weight: 700;
}

.logo p {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.9rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    color: var(--text-light);
}

.input-with-icon input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition);
    background: white;
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.error-message {
    background: #fef2f2;
    color: var(--error-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.login-help {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Catalog Styles */
.catalog-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.catalog-main {
    flex: 1;
    padding-top: 1rem;
    padding-bottom: 140px;
}

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

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

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    height: 50px;
    width: auto;
}

.brand-info h1 {
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.user-welcome {
    font-size: 0.9rem;
    color: var(--text-light);
}

.user-welcome strong {
    color: var(--primary-color);
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-left: 0.5rem;
}

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

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container i {
    position: absolute;
    left: 12px;
    color: var(--text-light);
}

.search-container input {
    padding: 10px 10px 10px 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    width: 300px;
    font-size: 14px;
    transition: var(--transition);
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.logout-btn {
    background: var(--error-color);
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: #e53e3e;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Filters Section */
.filters-section {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.filter-select {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    font-size: 14px;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

/* Stats Section */
.stats-section {
    margin-bottom: 2rem;
}

.stats-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 1rem;
}

.products-count, .visible-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.product-image {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: var(--transition);
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.no-image {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    background: #f7fafc;
    font-size: 0.9rem;
}

.stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-badge.in-stock {
    background: var(--success-color);
    color: white;
}

.stock-badge.out-of-stock {
    background: var(--error-color);
    color: white;
}

.product-info {
    padding: 1.2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6rem;
    cursor: pointer;
    transition: color 0.2s;
}

.product-name:hover {
    color: var(--primary-color);
}

.product-description {
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.product-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.product-sku, .product-category {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.product-sku strong, .product-category i {
    color: var(--text-dark);
}

.view-details-btn {
    width: 100%;
    padding: 10px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.view-details-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* No Products Message */
.no-products-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-products-message h3 {
    color: var(--text-dark);
    margin: 1rem 0 0.5rem;
    font-size: 1.5rem;
}

.no-products-message p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    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); }
}

.loading-spinner p {
    color: var(--text-light);
    font-size: 1rem;
}

.retry-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1rem;
}

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

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

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

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s;
}

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

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    z-index: 1001;
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.close-modal:hover {
    color: var(--error-color);
    background: #f8f9fa;
}

.modal-body {
    padding: 2rem;
}

.modal-product {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

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

.modal-image img {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-image-modal {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: var(--radius);
    color: var(--text-light);
}

.modal-info h2 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: var(--radius);
}

.modal-sku, .modal-category, .modal-stock {
    font-size: 0.9rem;
}

.modal-stock.in-stock {
    color: var(--success-color);
}

.modal-stock.out-of-stock {
    color: var(--error-color);
}

.modal-description h3 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.modal-description p {
    line-height: 1.6;
    color: var(--text-dark);
    white-space: pre-line;
}

/* Pagination */
.pagination-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid var(--border-color);
    padding: 1rem 1.5rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 90;
    backdrop-filter: blur(10px);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    max-width: 600px;
    margin: 0 auto;
}

.pagination-btn {
    padding: 14px 16px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    min-width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex: 1;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.pagination-nav {
    background: var(--secondary-color);
    border-color: var(--primary-color);
    font-weight: 700;
    flex: 1.2;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-dark);
    text-align: center;
    margin-top: 0.8rem;
    font-weight: 500;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .product-image {
        height: 280px;
    }
}

@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .product-image {
        height: 260px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    /* Compact Header */
    .catalog-header {
        padding: 0.5rem 0;
    }
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.5rem 0;
    }
    .brand-section {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-shrink: 1;
        min-width: 0;
    }
    .brand-logo {
        height: 35px;
    }
    .brand-info h1 {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .user-welcome {
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .user-email {
        display: none;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 0.75rem;
    }
    .search-container {
        flex: 1;
        min-width: 120px;
    }
    .search-container input {
        width: 100%;
        padding: 8px 8px 8px 32px;
        font-size: 0.8rem;
    }
    .search-container i {
        left: 8px;
    }
    .logout-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    /* Compact Filters */
    .filters-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .filter-group label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    .filter-select {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 40px;
    }
    
    /* Compact Stats */
    .stats-section {
        margin-bottom: 1rem;
    }
    .stats-container {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        flex-direction: column;
        align-items: flex-start;
    }
    .products-count, .visible-count {
        font-size: 0.8rem;
        gap: 4px;
    }
    
    /* Compact Products */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }
    .product-image {
        height: 160px;
    }
    .product-info {
        padding: 0.75rem;
    }
    .product-name {
        font-size: 0.85rem;
        min-height: 2.2rem;
        margin-bottom: 0.5rem;
    }
    .product-description {
        font-size: 0.75rem;
        -webkit-line-clamp: 2;
        margin-bottom: 0.75rem;
    }
    .product-meta {
        gap: 0.25rem;
    }
    .product-sku, .product-category {
        font-size: 0.7rem;
        gap: 4px;
    }
    .view-details-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
        margin-top: 0.75rem;
        min-height: 36px;
    }
    
    /* Compact Pagination */
    .catalog-main {
        padding-bottom: 100px;
    }
    .pagination-container {
        padding: 0.6rem 0.8rem;
    }
    .pagination {
        gap: 0.2rem;
    }
    .pagination-btn {
        padding: 8px 10px;
        min-width: 40px;
        height: 40px;
        font-size: 0.8rem;
        border-radius: 6px;
    }
    .pagination-nav {
        flex: 1;
        min-width: 45px;
    }
    .pagination-info {
        font-size: 0.75rem;
        margin-top: 0.4rem;
        padding: 0.3rem;
    }
    
    /* Compact Modal */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 95vh;
    }
    .modal-product {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .modal-image img {
        max-width: 100%;
    }
    .modal-body {
        padding: 1.5rem;
    }
    
    .stock-badge {
        padding: 4px 8px;
        font-size: 0.6rem;
        top: 6px;
        right: 6px;
    }
}

@media (max-width: 480px) {
    /* Extra Compact */
    .container {
        padding: 0 10px;
    }
    .brand-info h1 {
        font-size: 1rem;
    }
    .user-welcome {
        font-size: 0.7rem;
    }
    .header-actions {
        gap: 0.5rem;
    }
    .search-container input {
        padding: 6px 6px 6px 28px;
        font-size: 0.75rem;
    }
    .logout-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .product-image {
        height: 300px;
    }
    .product-info {
        padding: 0.5rem;
    }
    
    .catalog-main {
        padding-bottom: 90px;
    }
    .pagination-container {
        padding: 0.5rem 0.6rem;
    }
    .pagination-btn {
        padding: 6px 8px;
        min-width: 36px;
        height: 36px;
        font-size: 0.75rem;
    }
    
    /* Login page mobile */
    .login-body {
        padding: 10px;
    }
    .login-form {
        padding: 2rem 1.5rem;
    }
    .site-logo {
        max-width: 150px;
    }
    .logo h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 360px) {
    /* Super Compact */
    .brand-info h1 {
        font-size: 0.9rem;
    }
    .search-container {
        min-width: 100px;
    }
    .search-container input {
        font-size: 0.7rem;
    }
    .product-image {
        height: 300px;
    }
    .product-info {
        padding: 0.5rem;
    }
    .pagination-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.7rem;
        padding: 4px 6px;
    }
    .catalog-main {
        padding-bottom: 80px;
    }
    .modal-body {
        padding: 1rem;
    }
    .modal-meta {
        padding: 0.75rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .product-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    .view-details-btn:hover {
        transform: none;
        background: var(--primary-color);
    }
    .logout-btn:hover {
        transform: none;
        background: var(--error-color);
    }
    .view-details-btn,
    .logout-btn,
    .login-btn {
        min-height: 44px;
    }
    .filter-select {
        min-height: 44px;
    }
    .product-name {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .catalog-header {
        padding: 0.3rem 0;
    }
    .header-content {
        padding: 0.3rem 0;
    }
    .brand-logo {
        height: 30px;
    }
    .brand-info h1 {
        font-size: 0.9rem;
    }
    .user-welcome {
        font-size: 0.7rem;
    }
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .product-image {
        height: 120px;
    }
    .catalog-main {
        padding-bottom: 70px;
    }
    .modal-content {
        margin: 1% auto;
        max-height: 98vh;
    }
    .modal-product {
        grid-template-columns: 200px 1fr;
        gap: 1rem;
    }
    .modal-body {
        padding: 1rem;
    }
}

/* High-resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image img {
        image-rendering: -webkit-optimize-contrast;
    }
}