html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

#app {
    height: 100%;
}

/* ========== Global Page Loader ========== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader-content {
    background: linear-gradient(135deg, rgba(5, 39, 103, 0.98) 0%, rgba(58, 6, 71, 0.98) 100%);
    padding: 40px 50px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

/* Animated spinner with rotating border */
.loader-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #667eea;
    border-right: 4px solid #764ba2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.loader-dots span {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(1) { animation-delay: 0s; }
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loader-text {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 500;
    margin-top: 20px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.loader-subtext {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Payment processing specific loader */
.loader-payment-icon {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 15px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Success checkmark animation */
.loader-success {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: scaleIn 0.5s ease-out;
}

.loader-success i {
    font-size: 2.5rem;
    color: #fff;
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Component-level loading overlay */
.component-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: inherit;
}

.component-loader .spinner-border {
    width: 3rem;
    height: 3rem;
    color: #667eea;
}

/* ========== End Global Page Loader ========== */

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
    padding-bottom: 1.5rem;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHZpZXdCb3g9IjAgMCA1NiA0OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjEyNSAzMi44NzVIMTQuMTg3NUMyMy44NzUgMzIuODc1IDMyIDI0Ljc1IDMyIDE1LjA2MjVWMTNDMzIgNS44MjAzMTIgMzcuODIwMzEgMCA0NSAwSDU2VjQ0SDQ1QzM3LjgyMDMxIDQ0IDMyIDM4LjE3OTY5IDMyIDMxVjI5LjA2MjVDMzIgMTkuMzc1IDIzLjg3NSAxMS4yNSAxNC4xODc1IDExLjI1SDEzLjEyNVoiIGZpbGw9IiNGRkE4MDAiLz4KPC9zdmc+) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.sidebar {
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 3.5rem;
}

.nav-scrollable {
    flex: 1;
    overflow-y: auto;
    padding-top: 0.5rem;
}

.nav-link {
    color: #e2e8f0;
    border-radius: 4px;
    height: 2.4rem;
    display: flex;
    align-items: center;
    line-height: 2.4rem;
    font-size: 0.85rem;
    padding: 0 0.75rem;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.navbar-toggler {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.25rem 0.5rem;
}

.navbar-brand {
    font-size: 0.95rem;
    font-weight: 600;
    color: white !important;
}

@media (max-width: 640.98px) {
    .sidebar {
        width: 100%;
    }
    
    .collapse {
        display: none;
    }
    
    .collapse.show {
        display: block;
    }
}

.top-row {
    background: linear-gradient(90deg, #D6F5FF 0%, #ffffff 100%);
    border-bottom: 1px solid #ADD8E6;
    justify-content: flex-end;
    height: 2.8rem;
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    width: 100%;
}

main .top-row {
    background: linear-gradient(90deg, #D6F5FF 0%, #ffffff 100%);
    border-bottom: 1px solid #ADD8E6;
}

.top-row ::deep a, .top-row .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
}

.top-row a:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
    .top-row {
        display: flex;
        justify-content: center;
        padding: 0.5rem;
        flex-wrap: wrap;
        gap: 0.5rem;
        height: auto;
        min-height: auto;
    }
    
    .top-row > div {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem !important;
    }

    .top-row a, .top-row .btn-link, .top-row .btn {
        margin-left: 0;
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .top-row .balance-text {
        display: none;
    }
    
    .top-row .balance-badge {
        display: inline-flex;
    }
}

.page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
        align-items: flex-start;
    }

    .sidebar {
        width: 200px;
        min-width: 200px;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        overflow-y: auto;
        flex-shrink: 0;
        z-index: 1000;
    }
    
    .sidebar .collapse {
        display: block !important; /* Always show menu on desktop */
    }

    main {
        margin-left: 200px;
        width: calc(100% - 200px);
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }

    .top-row, article {
        padding-left: 2rem !important;
        padding-right: 1.5rem !important;
    }
    
    article {
        flex: 1;
        overflow-y: auto;
    }
    
    .navbar-toggler {
        display: none; /* Hide toggle button on desktop */
    }
}

@media (max-width: 640.98px) {
    .page {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: auto;
    }

    main {
        width: 100%;
        margin-left: 0;
    }
}

/* Table styling */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa;
}

/* Card styling */
.card {
    border: none;
    border-radius: 10px;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
}

.shadow {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* ========== Mobile Responsive Styles ========== */
@media (max-width: 767.98px) {
    /* Page headers */
    .page-header {
        margin: -0.5rem -0.5rem 0.5rem -0.5rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    .page-header h5 {
        font-size: 1rem;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    .card-header {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Tables */
    .table-compact {
        font-size: 0.7rem !important;
    }
    
    .table-compact th {
        font-size: 0.65rem !important;
        padding: 0.25rem !important;
    }
    
    .table-compact td {
        padding: 0.2rem !important;
    }
    
    /* Buttons */
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
    
    /* Forms */
    .form-control {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
    }
    
    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    /* Feature cards on home */
    .feature-card {
        padding: 0.75rem !important;
    }
    
    .feature-card .fs-3 {
        font-size: 1.25rem !important;
    }
    
    /* Hero section */
    .hero-section {
        padding: 1rem !important;
    }
    
    .hero-section h2 {
        font-size: 1.25rem;
    }
    
    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
    
    /* Container padding */
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Content area */
    .content {
        padding: 0.5rem !important;
    }
    
    /* Alert boxes */
    .alert {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Row gaps */
    .row.g-2 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
    
    .row.g-3 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
}
