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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
}

.min-h-screen {
    min-height: 100vh;
}

/* Sidebar styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 280px;
    background-color: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar.active {
    transform: translateX(0);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.overlay.active {
    display: block;
}

/* Main content */
.main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 280px;
    }
    
    .sidebar.active + .main-content {
        margin-left: 280px;
    }
}

/* Top bar */
header {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ========== BALANCE SECTION STYLES ========== */
.balance-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: relative;
    min-height: 100px;
}

/* Base card styles - hidden by default, shown via JS */
.balance-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 0.75rem;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    height: 80px;
    display: none;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.balance-card.show {
    display: flex;
}

/* Hide cards with zero/negative balance */
.balance-card.hide-card {
    display: none !important;
}

.balance-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.balance-card.cashout-balance {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.balance-card.smartpay-balance {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.balance-card.unsettlepg-balance {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
}

.balance-card.unsettlepos-balance {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.balance-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
}

.balance-amount {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.1rem;
}

.balance-subtitle {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* Balance Loading Overlay */
.balance-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.balance-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: balanceSpin 0.6s linear infinite;
}

@keyframes balanceSpin {
    to { transform: rotate(360deg); }
}

/* Balance section responsive grid */
@media (max-width: 768px) {
    .balance-section {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }
    .balance-card {
        min-width: auto;
    }
}

@media (min-width: 769px) and (max-width: 1023px) {
    .balance-section {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .balance-section {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* ========== INITIAL HIDE ALL SERVICE SECTIONS - PREVENT FLASH ========== */
/* Hide all service section containers initially */
.channel-section-container,
.recharge-section-container,
.banking-section-container,
.aeps-section-container,
.travel-section-container,
.reports-section-container,
.network-reports-section-container {
    display: none !important;
}

/* When sections are ready to show, JS will add this class */
.channel-section-container.section-ready,
.recharge-section-container.section-ready,
.banking-section-container.section-ready,
.aeps-section-container.section-ready,
.travel-section-container.section-ready,
.reports-section-container.section-ready,
.network-reports-section-container.section-ready {
    display: block !important;
}

/* Icon containers hidden by CSS - no flash possible */
.icon-container {
    display: none !important;
}

.icon-container.visible {
    display: block !important;
}

/* Loading placeholder for sections */
.section-loading-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    background: #f8fafc;
    border-radius: 12px;
    margin: 1rem 0;
}

.loading-spinner-small {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-text {
    margin-left: 12px;
    color: #64748b;
    font-size: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Service Popup */
.service-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.service-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.service-popup {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.service-popup-overlay.active .service-popup {
    transform: scale(1);
}

.service-popup-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.service-popup-icon i {
    font-size: 1.5rem;
    color: #dc2626;
}

.service-popup h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.service-popup p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.service-popup-btn {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
    width: 100%;
}

.service-popup-btn:hover {
    background: #b91c1c;
}

/* View All Button Styles */
.view-all-container {
    text-align: center;
    margin-top: 1rem;
    display: block !important;
}

.view-all-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    background: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    outline: none;
}

.view-all-btn:hover {
    background: #2563eb;
}

.view-all-container.hidden {
    display: none !important;
}

/* Section Icons Grid */
.section-icons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

/* ========== MOBILE RESPONSIVE STYLES ========== */
@media (max-width: 768px) {
    .section-icons {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem;
    }
    
    .section-icons .icon-container.visible {
        display: block !important;
    }
    
    /* Show only first 3 items in collapsed state */
    .section-icons:not(.expanded):not(.franchisee-reports) .icon-container.visible:nth-child(n+4) {
        display: none !important;
    }
    
    /* Show all items when expanded */
    .section-icons.expanded .icon-container.visible {
        display: block !important;
    }
    
    /* Specific section overrides */
    #reports-section .icon-container.visible,
    #network-reports-section .icon-container.visible,
    #aeps-section .icon-container.visible,
    #travel-section .icon-container.visible,
    #banking-section .icon-container.visible,
    #recharge-section .icon-container.visible,
    #channel-section .icon-container.visible {
        display: block !important;
    }
    
    /* Collapse limit for non-expanded sections */
    #reports-section:not(.expanded):not(.franchisee-reports) .icon-container.visible:nth-child(n+4),
    #network-reports-section:not(.expanded) .icon-container.visible:nth-child(n+4),
    #aeps-section:not(.expanded) .icon-container.visible:nth-child(n+4),
    #travel-section:not(.expanded) .icon-container.visible:nth-child(n+4),
    #banking-section:not(.expanded) .icon-container.visible:nth-child(n+4),
    #recharge-section:not(.expanded) .icon-container.visible:nth-child(n+4),
    #channel-section:not(.expanded) .icon-container.visible:nth-child(n+4) {
        display: none !important;
    }
    
    /* Expanded sections show all */
    #reports-section.expanded .icon-container.visible,
    #reports-section.franchisee-reports .icon-container.visible,
    #network-reports-section.expanded .icon-container.visible,
    #aeps-section.expanded .icon-container.visible,
    #travel-section.expanded .icon-container.visible,
    #banking-section.expanded .icon-container.visible,
    #recharge-section.expanded .icon-container.visible,
    #channel-section.expanded .icon-container.visible {
        display: block !important;
    }
}

/* Desktop styles */
@media (min-width: 769px) {
    .section-icons {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
        gap: 1rem;
    }
    
    .section-icons .icon-container.visible {
        display: block !important;
    }
    
    .view-all-container {
        display: none !important;
    }
}

/* ========== FRANCHISEE REPORTS SECTION - SHOW ALL ITEMS ========== */
/* For Franchisee users, show all report items without view all button */
.franchisee-reports .icon-container.visible {
    display: block !important;
}

/* Ensure all report items are visible in grid */
.franchisee-reports {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
    gap: 1rem;
}

/* Mobile view for Franchisee reports */
@media (max-width: 768px) {
    .franchisee-reports {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem;
    }
    
    .franchisee-reports .icon-container.visible {
        display: block !important;
    }
    
    /* Ensure all report items are visible for Franchisee users */
    .franchisee-reports .icon-container.visible:nth-child(n) {
        display: block !important;
    }
}

/* Hide view all button for Franchisee reports section */
.franchisee-reports ~ .view-all-container,
#reports-section.franchisee-reports + .view-all-container,
.reports-section-container .franchisee-reports ~ .view-all-container {
    display: none !important;
}

/* Ensure section container is visible */
.reports-section-container.section-ready {
    display: block !important;
}

/* Network reports section for Franchisee/Master Distributor/Area Distributor */
.network-reports-section-container.section-ready {
    display: block !important;
}

/* Additional styles for section containers */
.section-container-hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force display for important elements */
.force-show {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure no conflicting styles */
#reports-section,
.reports-section-container,
.reports-section-container .section-icons {
    min-height: auto !important;
}

/* Make sure report items have proper dimensions */
#reports-section .icon-container {
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Ensure consistent icon sizes */
#reports-section .icon-animation,
#reports-section .icon-circle {
    width: 40px;
    height: 40px;
}

/* Responsive text for labels */
#reports-section .icon-label {
    font-size: 0.8rem;
    text-align: center;
    margin-top: 0.5rem;
    line-height: 1.2;
}

/* ========== ADDITIONAL UTILITY CLASSES ========== */
.hidden {
    display: none !important;
}

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

.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.p-6 {
    padding: 1.5rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.shadow-md {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.bg-white {
    background-color: #ffffff;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-600 {
    color: #4b5563;
}

.text-2xl {
    font-size: 1.5rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.text-lg {
    font-size: 1.125rem;
}

/* Animation keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Carousel Styles */
.promotional-banner {
    position: relative;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
}

.banner-carousel {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.banner-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    background-size: cover;
    background-position: center;
}

.banner-slide:nth-child(1) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.banner-slide:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.banner-slide:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.banner-slide:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.banner-slide.active {
    opacity: 1;
}

.banner-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.banner-content p {
    font-size: 1rem;
    margin-bottom: 1rem;
    opacity: 0.9;
    color: white;
}

.cta-button {
    background-color: white;
    color: #333;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.carousel-indicators {
    position: absolute;
    bottom: 1rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    z-index: 10;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background-color: white;
    transform: scale(1.2);
}

.carousel-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    transform: translateY(-50%);
    z-index: 10;
}

.carousel-control {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.carousel-control:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Mobile carousel adjustments */
@media (max-width: 768px) {
    .promotional-banner {
        height: 160px;
    }
    
    .banner-content h3 {
        font-size: 1.1rem;
    }
    
    .banner-content p {
        font-size: 0.8rem;
    }
    
    .carousel-control {
        width: 30px;
        height: 30px;
    }
}