/* Reset and Base 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;
    color: #333;
}

/* Page Management */
.page {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Role-based visibility */
body:not(.is-admin) .admin-only {
    display: none !important;
}

/* Hide user & data management from dealers */
body.is-dealer [data-section="user-management"],
body.is-dealer [data-section="data-management"],
body.is-dealer [data-section="categories"],
body.is-dealer [data-section="storefront"] {
    display: none !important;
}

/* Login Page Styles */
#loginPage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.login-box h2 {
    color: #666;
    margin-bottom: 30px;
    font-weight: 300;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.input-group input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    background: #ffeaea;
    display: none;
}

/* Button Styles */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

/* Dashboard Layout */
#dashboardPage {
    min-height: 100vh;
    background: #f8f9fa;
}

.navbar {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.main-container {
    display: flex;
    min-height: calc(100vh - 70px);
}

.sidebar {
    width: 250px;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.nav-menu {
    list-style: none;
    padding: 20px 0;
}

.nav-menu li {
    margin-bottom: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s;
}

.nav-link:hover {
    background: #f8f9fa;
    color: #667eea;
}

.nav-link.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border-right: 4px solid #667eea;
}

/* Content Area */
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.content h2 {
    margin-bottom: 30px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    font-size: 2.5rem;
    color: #667eea;
}

.stat-info h3 {
    font-size: 2rem;
    margin-bottom: 5px;
    color: #333;
}

.stat-info p {
    color: #666;
    font-size: 0.9rem;
}

/* Section Cards */
.section-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.section-card h3 {
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f8f9fa;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area input[type="file"] {
    display: none;
}

.upload-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #666;
}

.upload-label i {
    font-size: 3rem;
    color: #667eea;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
}

.filter-controls select {
    flex: 1;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 16px;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table th,
table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

table tr:hover {
    background: #f8f9fa;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.category-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    border-left: 5px solid;
    transition: transform 0.3s;
}

.category-card:hover {
    transform: translateY(-3px);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.category-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.category-description {
    color: #666;
    font-size: 0.9rem;
}

.category-actions {
    display: flex;
    gap: 5px;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }
    
    .nav-menu li {
        margin-bottom: 0;
        margin-right: 10px;
    }
    
    .nav-link {
        white-space: nowrap;
        padding: 10px 15px;
    }
    
    .content {
        padding: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

/* ===================================
   Storefront Management Styles
   =================================== */

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* Gallery Grid */
.gallery-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    cursor: pointer;
    aspect-ratio: 1;
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: white;
    margin-top: auto;
}

.gallery-info strong {
    font-size: 14px;
}

.gallery-info .badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    font-size: 11px;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    width: fit-content;
}

.gallery-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.9);
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: white;
    transform: scale(1.1);
}

.btn-icon.btn-delete {
    color: #e74c3c;
}

.inactive-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e74c3c;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Offers List */
.offers-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.offer-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    transition: all 0.3s;
}

.offer-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.offer-card.inactive {
    opacity: 0.6;
    border-color: #ccc;
}

.offer-card.expired {
    background: #fff5f5;
    border-color: #ffcccc;
}

.offer-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.offer-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.offer-content h4 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.offer-content p {
    margin: 0;
    color: #666;
}

.offer-pricing {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.original-price {
    font-size: 16px;
    color: #999;
    text-decoration: line-through;
}

.sale-price {
    font-size: 24px;
    font-weight: 700;
    color: #27ae60;
}

.discount-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #e74c3c;
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

.offer-expiry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    border-radius: 8px;
    font-size: 14px;
    color: #856404;
}

.offer-expiry.expired {
    background: #f8d7da;
    color: #721c24;
}

.offer-expiry i {
    font-size: 16px;
}

.offer-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .offer-card {
        grid-template-columns: 1fr;
    }
    
    .offer-card img {
        height: 150px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

.toast.toast-success {
    border-left: 4px solid #27ae60;
}

.toast.toast-success i {
    color: #27ae60;
}

.toast.toast-error {
    border-left: 4px solid #e74c3c;
}

.toast.toast-error i {
    color: #e74c3c;
}

.toast.fade-out {
    animation: slideOut 0.3s ease-in;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}