/* assets/custom_styles.css */

/* ========================================
   NAVBAR GRADIENT STYLING
   ======================================== */

/* Navbar gradient background and styling */
.navbar-gradient {
    background: linear-gradient(135deg, #6278F5 0%, #39B5A4 100%) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Navbar brand styling */
.navbar-gradient .navbar-brand {
    color: white !important;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
}

/* Navbar link custom styling */
.navbar-link-custom {
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.35rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.navbar-link-custom:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Navbar toggler for mobile */
.navbar-gradient .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5);
}

.navbar-gradient .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.9%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Responsive navbar collapse */
@media (max-width: 991px) {
    .navbar-gradient .navbar-collapse {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 0.35rem;
        margin-top: 0.5rem;
        padding: 0.5rem;
    }
}

/* ========================================
   WCAG AA Compliant Color System
   ======================================== */
:root {
    /* Primary colors (Bootstrap LUX compatible) */
    --color-primary: #0d6efd;
    --color-primary-dark: #0a58ca;
    --color-primary-light: #6ea8fe;

    /* Semantic colors */
    --color-success: #198754;
    --color-warning: #ffc107;
    --color-danger: #dc3545;
    --color-info: #0dcaf0;

    /* Neutral colors - Enhanced contrast */
    --color-text-primary: #212529;    /* 14.75:1 on white */
    --color-text-secondary: #495057;  /* 9.17:1 on white */
    --color-text-tertiary: #6c757d;   /* 5.64:1 on white */
    --color-text-disabled: #adb5bd;   /* 3.07:1 on white - use only for large text */

    /* Backgrounds */
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f8f9fa;
    --color-bg-tertiary: #e9ecef;
    --color-bg-dark: #343a40;

    /* Borders */
    --color-border-light: #dee2e6;
    --color-border-medium: #adb5bd;
    --color-border-dark: #6c757d;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.2);

    /* Focus ring */
    --focus-ring-color: #FFC107;
    --focus-ring-width: 3px;
    --focus-ring-offset: 2px;
}

/* Apply to common elements */
body {
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
}

.form-label,
.dbc-label {
    color: var(--color-text-secondary);
}

.text-muted {
    color: var(--color-text-tertiary) !important;
}

/* Enhanced Card contrast */
.card-header {
    background-color: var(--color-bg-secondary);
    border-bottom: 2px solid var(--color-border-light);
    color: var(--color-text-primary);
    font-weight: 600;
}

/* ========================================
   Enhanced Sidebar with Light Theme
   ======================================== */
.sidebar {
    padding: 0;
    margin: 0;
    background: #f8f9fa;
    color: var(--color-text-primary);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    border-right: 1px solid var(--color-border-light);
}

.sidebar h4 {
    color: var(--color-text-primary);
    font-weight: 700;
    padding: 20px 20px 10px 20px;
    margin: 0;
}

.sidebar hr {
    border-color: var(--color-border-light);
    margin: 10px 20px;
}

/* Mobile sidebar styles */
@media (max-width: 767px) {
    #sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1050;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }

    #sidebar.show {
        transform: translateX(0);
    }
}

/* Hide navbar hamburger menu and GitHub link on mobile */
@media (max-width: 767px) {
    .navbar-toggler {
        display: none !important;
    }

    .navbar-nav {
        display: none !important;
    }
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Close button in sidebar */
.btn-close-sidebar {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    padding: 5px;
    transition: color 0.2s;
}

.btn-close-sidebar:hover {
    color: #000;
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Enhanced Sidebar Navigation Links with Gradient Button Style */
.sidebar .nav-link {
    color: var(--color-text-secondary);
    transition: all 0.3s ease;
    border-radius: 0.35rem;
    margin: 0.25rem 20px;
    padding: 0.625rem 1rem;
    background-size: 200% auto;
}

.sidebar .nav-link:hover:not(.active) {
    color: var(--color-primary);
    background-color: var(--color-bg-tertiary);
}

.sidebar .nav-link.active {
    background-image: linear-gradient(to right, #6278F5 0%, #39B5A4 51%, #6278F5 100%);
    background-size: 200% auto;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.sidebar .nav-link.active:hover {
    background-position: right center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Enhanced Content Container with Responsive Padding */
.content-container {
    padding: 0.5rem;
    margin-left: 0;
    margin-top: 0;
    min-height: calc(100vh - 56px); /* Account for navbar height */
    transition: margin-left 0.3s ease-in-out, padding 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .content-container {
        padding: 0.75rem;
    }
}

/* Medium devices (tablets, 768px and up) - Sidebar appears */
@media (min-width: 768px) {
    .content-container {
        margin-left: 20rem; /* Match sidebar width */
        padding: 0.75rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .content-container {
        padding: 0.75rem;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .content-container {
        padding: 0.75rem;
    }
}

/* Form label responsive sizing */
.form-label-sm {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #495057;
}

@media (min-width: 768px) {
    .form-label-sm {
        font-size: 0.95rem;
    }
}

/* Reduce card spacing on desktop */
@media (min-width: 768px) {
    .card-body {
        padding: 0.5rem;
    }

    .card {
        margin-bottom: 0;
    }

    /* Reduce gutter spacing */
    .g-2 {
        --bs-gutter-x: 0;
        --bs-gutter-y: 0;
    }
}

/* Enhanced Tab Styling with Gradient Button Style */

/* Tab container */
.nav-tabs {
    border-bottom: 2px solid #dee2e6;
    padding-left: 0;
}

.nav-tabs .nav-item {
    margin-bottom: -2px;
}

/* Base tab styling */
.nav-tabs .nav-link {
    color: #6c757d;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-bottom: none;
    border-radius: 0.35rem 0.35rem 0 0;
    padding: 0.75rem 1.5rem;
    margin-right: 0.25rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    background-size: 200% auto;
}

/* Hover effect */
.nav-tabs .nav-link:hover:not(.active) {
    color: #0d6efd;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

/* Active tab - Gradient button style */
.nav-tabs .nav-link.active {
    background-image: linear-gradient(to right, #6278F5 0%, #39B5A4 51%, #6278F5 100%);
    background-size: 200% auto;
    color: white;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border-bottom: none;
}

/* Active tab hover effect */
.nav-tabs .nav-link.active:hover {
    background-position: right center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Focus state for accessibility */
.nav-tabs .nav-link:focus {
    outline: 2px solid #FFC107;
    outline-offset: 2px;
}

/* Mobile responsive tabs */
@media (max-width: 576px) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .nav-tabs .nav-link {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }
}

/* Pills variant (for sidebar navigation) - Gradient Button Style */
.nav-pills .nav-link {
    color: var(--color-text-secondary);
    background-color: transparent;
    border-radius: 0.35rem;
    padding: 0.625rem 1rem;
    margin: 0.25rem 20px;
    transition: all 0.3s ease;
    font-weight: 500;
    background-size: 200% auto;
}

.nav-pills .nav-link:hover:not(.active) {
    background-color: var(--color-bg-tertiary);
    color: var(--color-primary);
}

.nav-pills .nav-link.active {
    background-image: linear-gradient(to right, #6278F5 0%, #39B5A4 51%, #6278F5 100%);
    background-size: 200% auto;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.nav-pills .nav-link.active:hover {
    background-position: right center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* === 强化 Card 默认样式 === */
.card {
    border: 1px solid #dee2e6;    /* Bootstrap 默认浅灰边框 */
    border-radius: 0.25rem;       /* 圆角 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);  /* 轻微阴影 */
    background-color: #ffffff;    /* 白色背景 */
    padding: 1rem;                /* 内边距（也可用 className 控制） */
    margin-bottom: 1rem;          /* 与下一个元素的间距 */
}

/* === Map Container Constraints === */
.map-graph-container {
    max-width: 100%;
    margin: 0 auto;
    display: block;
}

/* Prevent map from stretching too much on very wide screens */
@media (min-width: 1400px) {
    .map-graph-container {
        max-width: 1400px;
    }
}

/* Responsive height adjustments */
@media (max-width: 768px) {
    .map-graph-container {
        height: 50vh !important;
        min-height: 300px !important;
        max-height: 500px !important;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .map-graph-container {
        max-height: 700px !important;
    }
}

/* ========================================
   Enhanced Custom Gradient Button with Accessibility
   ======================================== */
.custom-gradient-button {
    background-image: linear-gradient(to right, #6278F5 0%, #39B5A4 51%, #6278F5 100%);
    margin: 5px 0;
    padding: 12px 28px;    /* Increased for better touch targets */
    min-height: 44px;      /* WCAG 2.1 minimum touch target */
    text-align: center;
    text-transform: none;
    transition: all 0.3s ease;
    background-size: 200% auto;
    color: white;
    border-radius: 25px;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    letter-spacing: 0.5px;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

/* Hover state - Enhanced */
.custom-gradient-button:hover:not(:disabled) {
    background-position: right center;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transform: translateY(-1px);
}

/* Focus state - WCAG compliant */
.custom-gradient-button:focus {
    outline: 3px solid #FFC107;
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 4px rgba(255, 193, 7, 0.2);
}

/* Focus-visible for keyboard navigation */
.custom-gradient-button:focus-visible {
    outline: 3px solid #FFC107;
    outline-offset: 2px;
}

/* Active/pressed state */
.custom-gradient-button:active:not(:disabled) {
    background-position: right center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) inset;
    transform: translateY(1px);
}

/* Disabled state */
.custom-gradient-button:disabled,
.custom-gradient-button.disabled {
    background-image: linear-gradient(to right, #95a5ff 0%, #8cd5ca 51%, #95a5ff 100%);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

/* Loading state */
.custom-gradient-button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.custom-gradient-button.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: button-loading-spinner 0.6s linear infinite;
}

@keyframes button-loading-spinner {
    from { transform: rotate(0turn); }
    to { transform: rotate(1turn); }
}

/* ========================================
   Enhanced DataTable Performance & Styling
   ======================================== */

/* Table pagination controls */
.table-pagination-controls {
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.table-pagination-controls .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Pagination info styling */
#pagination-info {
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* DataTable cell responsive font */
@media (max-width: 768px) {
    .dash-spreadsheet td,
    .dash-spreadsheet th {
        font-size: 12px !important;
    }
}

/* Ensure consistent row heights for virtualization */
.dash-spreadsheet tr {
    height: 56px;
    min-height: 56px;
}

/* Enhanced table hover effect */
.dash-spreadsheet tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05) !important;
    cursor: pointer;
}

/* Selected row state */
.dash-spreadsheet .cell--selected {
    background-color: rgba(13, 110, 253, 0.1) !important;
    border: 2px solid #0d6efd !important;
}

/* Improve table scrolling performance */
.dash-spreadsheet {
    will-change: transform;
    contain: layout style paint;
}

/* Loading spinner container for table */
.spinner-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   HOME PAGE STYLING
   ======================================== */

/* Hero Section */
.hero-section {
    position: relative;
    background: linear-gradient(135deg, #6278F5 0%, #39B5A4 100%);
    height: 550px; /* Fixed height to prevent stretching */
    display: flex;
    align-items: center;
    overflow: hidden;
}

/* Responsive hero height */
@media (max-width: 768px) {
    .hero-section {
        height: 400px;
    }
}

@media (max-width: 576px) {
    .hero-section {
        height: 350px;
    }
}

.hero-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: rgba(255,255,255,0.95);
    max-width: 700px;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.hero-buttons {
    margin-top: 2rem;
}

/* Responsive hero text */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }
}

/* Stats Section */
.stats-section {
    margin-top: -60px;
    position: relative;
    z-index: 10;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.stat-label {
    font-size: 0.95rem;
    color: #6c757d;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive stat cards */
@media (max-width: 992px) {
    .stat-number {
        font-size: 2rem;
    }
}

@media (max-width: 576px) {
    .stat-card {
        padding: 1.5rem 1rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }
}

/* Feature Cards Section */
.features-section {
    padding: 3rem 0;
}

.feature-card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    transition: all 0.3s ease;
    background: white;
    height: 100%;
    overflow: hidden;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15) !important;
    border-color: #6278F5;
}

.feature-card .card-title {
    font-weight: 600;
    color: #212529;
    margin-bottom: 1rem;
}

.feature-card .card-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.feature-card .fa-check-circle {
    color: #39B5A4;
}

/* Responsive feature cards */
@media (max-width: 768px) {
    .feature-card .card-title {
        font-size: 1.25rem;
    }

    .feature-card .card-text {
        font-size: 0.9rem;
    }
}

/* Technology Stack Section - Auto stick to bottom */
.tech-stack-section {
    padding: 1.5rem 0 2rem 0;
    background-color: #f8f9fa;
    margin-top: auto; /* Push to bottom of flex container */
    border-top: 1px solid #dee2e6;
    width: 100%;
}

.tech-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s ease;
    margin: 0.25rem;
}

.tech-badge:hover {
    background: linear-gradient(135deg, #6278F5 0%, #39B5A4 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(98, 120, 245, 0.3);
}

.tech-badge i {
    margin-right: 0.5rem;
}

/* Responsive tech badges */
@media (max-width: 576px) {
    .tech-badge {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
    }
}

/* Home Page Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.hero-section .container {
    animation: fadeIn 0.8s ease-out;
}

.stat-card {
    animation: fadeInUp 0.6s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

.feature-card {
    animation: fadeInUp 0.6s ease-out;
}

.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }

/* Home page specific button styles */
.home-page .custom-gradient-button {
    font-size: 1.1rem;
    padding: 14px 32px;
}

.home-page .btn-outline-light {
    color: white;
    border-color: white;
    transition: all 0.3s ease;
}

.home-page .btn-outline-light:hover {
    background-color: white;
    color: #6278F5;
    border-color: white;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}