/* ============================================
   ROOT VARIABLES
   ============================================ */
:root {
    --bs-primary: #023758;
    --bs-primary-rgb: 2, 55, 88;
    --bs-body-font-family: 'Inter', system-ui, sans-serif;
    --color-primary: #023758;
    --color-primary-light: #4CA4D8;
    --color-secondary: #2DB5AA;
    --color-bg-light: #F8F9FA;
    --color-bg-dark: #1C1F26;
    --color-text-dark: #023758;
    --color-text-light: #E5E7EB;
}

/* ============================================
   BASE STYLES (Homepage & General)
   ============================================ */
html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

main {
    display: block;
    width: 100%;
}

body {
    font-family: var(--bs-body-font-family);
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    margin-bottom: 60px;
}

a {
    color: var(--color-primary);
}

    a:hover {
        color: var(--color-primary-light);
    }

.lead strong,
.lead b {
    font-weight: 700 !important;
    color: var(--color-primary);
}

/* Fix flex children not shrinking and causing horizontal overflow */
.d-flex > .flex-grow-1 {
    min-width: 0;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    font-weight: 500;
    transition: all 0.2s ease;
}

    .btn-primary:hover {
        background-color: var(--color-primary-light);
        border-color: var(--color-primary-light);
        transform: translateY(-2px);
    }

.btn-outline-secondary {
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
    transition: all 0.2s ease;
}

    .btn-outline-secondary:hover {
        background-color: #e9ecef;
        transform: translateY(-2px);
    }

/* ============================================
   PRICING
   ============================================ */
.card .list-group {
    border: none;
    padding-left: 0;
    padding-right: 0;
}

.billing-toggle .btn {
    border-radius: 0;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--bs-primary);
    background-color: transparent;
    color: var(--bs-primary);
}

    .billing-toggle .btn.active {
        background-color: var(--bs-primary);
        color: white;
        z-index: 1;
    }

    .billing-toggle .btn:hover:not(.active) {
        background-color: rgba(2, 55, 88, 0.1);
    }

.billing-toggle .btn-group .btn:first-child {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
}

.billing-toggle .btn-group .btn:last-child {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

.billing-toggle .badge {
    font-size: 0.75rem;
    vertical-align: middle;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero-section {
    position: relative;
    padding: 7rem 1rem 9rem;
    background: linear-gradient(180deg, #f8fafc 0%, #dde3ea 100%);
}

    .hero-section h1 {
        font-size: 3.2rem;
        line-height: 1.2;
        color: var(--color-primary);
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

@media (min-width: 768px) {
    .hero-section h1 {
        font-size: 4rem;
    }
}

.hero-section p {
    color: var(--color-primary);
}

.hero-section .btn-light {
    background-color: #ffffff;
    color: var(--bs-primary);
    font-weight: 600;
    border: 2px solid var(--bs-primary);
    transition: all 0.2s ease;
}

    .hero-section .btn-light:hover {
        background-color: var(--bs-primary);
        color: #ffffff;
    }

.hero-section .btn-outline-secondary:hover {
    background-color: var(--color-primary);
    color: #ffffff;
    transform: translateY(-2px);
}

/* ============================================
   SCROLL CUE
   ============================================ */
.hero-section .scroll-cue {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 40px;
    border: 2px solid var(--bs-primary);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 6px;
}

    .hero-section .scroll-cue span {
        display: block;
        width: 4px;
        height: 8px;
        background-color: var(--bs-primary);
        border-radius: 2px;
        animation: scrollCue 1.2s infinite;
    }

@keyframes scrollCue {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    50% {
        transform: translateY(6px);
        opacity: 0.6;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   SECTIONS & HEADINGS
   ============================================ */
section h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

h1, h2, h3, h4, h5 {
    color: var(--color-primary);
    font-weight: 700;
}

/* ============================================
   ICONS & FEATURES
   ============================================ */
.home-icons img {
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease;
    height: 150px;
}

    .home-icons img:hover {
        transform: scale(1.05);
    }

/* ============================================
   FEATURES GRID
   ============================================ */
.bg-light {
    background-color: #f8fafc !important;
}

    .bg-light p {
        color: #4a5568;
    }

.table td.highlight {
    background-color: #e7f1fa; /* subtle Nabuza blue tint */
    font-weight: 500;
}

/* ============================================
   HOW IT WORKS
   ============================================ */
.how-it-works img {
    height: 150px;
    max-width: 100%;
}

.how-it-works h5 {
    font-weight: 600;
    margin-top: 1rem;
}

/* ============================================
   CTA SECTION
   ============================================ */
.cta-section {
    padding: 7rem 1rem;
    background: linear-gradient(135deg, #023758 0%, #0465a5 100%) !important;
    color: #ffffff;
}

    .cta-section h2,
    .cta-section p {
        color: #ffffff;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    .cta-section h2 {
        font-size: 2.9rem;
        line-height: 1.3;
    }

    .cta-section .btn-light {
        background-color: #ffffff;
        color: var(--bs-primary);
        font-weight: 700;
        border: 2px solid #ffffff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        padding: 0.9rem 2.4rem;
        transition: all 0.2s ease;
    }

        .cta-section .btn-light:hover {
            background-color: var(--bs-primary);
            color: #ffffff;
            transform: translateY(-3px);
        }

/* ============================================
   ANIMATIONS
   ============================================ */
[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

    [data-animate].in-view {
        opacity: 1;
        transform: translateY(0);
    }

.feature-grid > div,
.how-it-works-grid > div {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.feature-grid.in-view > div,
.how-it-works-grid.in-view > div {
    opacity: 1;
    transform: translateY(0);
}

.feature-grid > div:nth-child(1) {
    transition-delay: 0.1s;
}

.feature-grid > div:nth-child(2) {
    transition-delay: 0.2s;
}

.feature-grid > div:nth-child(3) {
    transition-delay: 0.3s;
}

.feature-grid > div:nth-child(4) {
    transition-delay: 0.4s;
}

.how-it-works-grid > div:nth-child(1) {
    transition-delay: 0.1s;
}

.how-it-works-grid > div:nth-child(2) {
    transition-delay: 0.2s;
}

.how-it-works-grid > div:nth-child(3) {
    transition-delay: 0.3s;
}

.how-it-works-grid > div:nth-child(4) {
    transition-delay: 0.4s;
}

.how-it-works-grid > div:nth-child(5) {
    transition-delay: 0.5s;
}

.how-it-works-grid > div:nth-child(6) {
    transition-delay: 0.6s;
}

.scroll-fade {
    opacity: 0.3;
    transition: opacity 0.5s ease-out;
}

    .scroll-fade.in-view {
        opacity: 1;
    }

/* ============================================
   FOOTER
   ============================================ */
footer {
    background-color: #f8fafc;
    color: var(--color-text-dark);
    padding: 2rem 0;
}

    footer a {
        color: var(--color-primary);
    }

        footer a:hover {
            color: var(--color-primary-light);
        }

/* ============================================
   LOADING OVERLAY (Shared)
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11000 !important;
}

.spinner-logo {
    width: 80px;
    height: 80px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   API WIZARD & TABLES
   ============================================ */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    }

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 12px 12px 0 0 !important;
}

.table {
    margin-bottom: 0;
}

    .table th {
        font-weight: 600;
        background-color: #f4f6f9;
        color: var(--color-primary);
        border-top: none;
    }

.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #f8fafc;
}

.table td {
    vertical-align: middle;
}

.list-group-item {
    border: none;
    border-bottom: 1px solid #eaeaea;
    padding: 0.75rem 1rem;
}

    .list-group-item:last-child {
        border-bottom: none;
    }

.btn-lg {
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

    .btn-lg:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
    }

.api-summary-heading {
    color: var(--color-primary);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.table-scroll {
    display: block;
    max-height: 400px;
    width: 100%;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    /* Force scrollbars to appear when needed */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #aaa #f0f0f0;
}

    .table-scroll table {
        width: max-content; /* Allow horizontal scroll when columns are wide */
        min-width: 100%; /* Ensure table at least fills container */
    }

    .table-scroll thead th {
        position: sticky;
        top: 0;
        background-color: #023758;
        color: #fff;
        z-index: 2;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .table-scroll::-webkit-scrollbar {
        height: 8px; /* Horizontal scrollbar height */
    }

    .table-scroll::-webkit-scrollbar-track {
        background: #f0f0f0;
    }

    .table-scroll::-webkit-scrollbar-thumb {
        background-color: #aaa;
        border-radius: 4px;
    }

.table-warning {
    background: linear-gradient(to right, #fff8e1 0%, #fff3cd 50%, #fff8e1 100%);
    font-style: italic;
    font-size: 0.95rem;
    animation: pulseFade 2.5s infinite ease-in-out;
    border-top: 2px solid #ffeeba;
}

@keyframes pulseFade {
    0% {
        opacity: 0.9;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.9;
    }
}

/* ============================================
   TOOLTIP STYLES
   ============================================ */
.tooltip-inner {
    background-color: #023758;
    color: #fff;
    font-size: 0.85rem;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: #023758;
}

/* ============================================
   ALERT STYLES
   ============================================ */
.alert-info {
    background-color: #e9f4fc;
    border-color: #b6e0f5;
    color: #023758;
    font-weight: 500;
}

/* ============================================
   STUDIO LAYOUT (App)
   ============================================ */
.studio-body {
    height: 100%;
    overflow: hidden;
}

.studio-main {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.studio-sidebar {
    width: 240px;
    min-width: 240px;
    background-color: #ffffff;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    padding: 1rem;
}

.studio-canvas {
    flex: 1;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 1rem;
}

.studio-canvas-content {
    /*max-width: 1200px;*/
    margin: 0 auto;
}

.studio-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #dee2e6;
    background-color: #ffffff;
}

.project-name[contenteditable="true"] {
    border-bottom: 2px dashed transparent;
    cursor: text;
    transition: border-bottom 0.2s ease;
}

    .project-name[contenteditable="true"]:focus {
        border-bottom: 2px dashed #4CA4D8;
        outline: none;
    }

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.save-indicator {
    font-size: 0.9rem;
    opacity: 1;
    transition: opacity 0.3s ease;
    vertical-align: middle;
}

    .save-indicator.show {
        opacity: 1;
    }

.hover-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

    .hover-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 4px 25px rgba(0,0,0,0.15) !important;
    }

/* Source Cards */
.sources-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-card {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
}

.source-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: var(--color-primary-light);
}

.source-card.selected {
    border-color: var(--color-primary);
    background-color: #f8f9fa;
    box-shadow: 0 0 0 2px rgba(2, 55, 88, 0.2);
}

.source-card .card-title {
    font-size: 0.875rem;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.source-card:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(2, 55, 88, 0.2);
}

/* Pending source specific styling */
.source-card.pending-source {
    pointer-events: none;
    cursor: default;
}

.source-card.pending-source:hover {
    transform: none;
}

.source-card.pending-source .progress {
    height: 0.5rem;
}

/* Sticky table headers for data view */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bs-dark) !important;
}

/* Rules indicator styling for columns with active rules */
th.has-rules {
    border-left: 4px solid #ffc107;
}

    th.has-rules .bi-stars {
        color: #ffc107;
        animation: gentle-pulse 2s ease-in-out infinite;
    }

.btn-icon-only {
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
    cursor: pointer;
    line-height: 1;
}

@keyframes gentle-pulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Rule chips styling */
.rule-chip {
    background-color: var(--color-primary);
    color: white;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
}

.rule-chip:hover {
    background-color: var(--color-primary-light);
    transform: translateY(-1px);
}

.rule-chip .btn-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.6rem;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.rule-chip .btn-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

#rulesContainer {
    padding: 0.25rem 0;
}

#rulesModal .modal-body {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

#rulesModal h6 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#rulesModal .form-select {
    max-width: 400px;
}


/* ============================================
   RESPONSIVE FIXES
   ============================================ */
@media (max-width: 992px) {
    .studio-sidebar {
        width: 200px;
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    .studio-main {
        flex-direction: column;
    }

    .studio-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        height: auto;
        max-height: 200px;
    }

    .studio-canvas {
        height: calc(100vh - 56px - 200px);
    }
}

/* ============================================
   SOURCE CARD ACTIONS
   ============================================ */
.source-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.source-card:hover .source-actions {
    opacity: 1;
}

.source-actions .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.source-actions .btn:hover {
    transform: scale(1.05);
}

/* ============================================
   DATASET CARDS
   ============================================ */
.dataset-card {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

.dataset-card:hover {
    border-color: #0d6efd;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.dataset-card:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.dataset-card.selected {
    border-color: #0d6efd;
    background-color: #f8f9fa;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.dataset-card.processing {
    border-left: 4px solid #ffc107;
}

.badge-completed {
    background-color: #198754;
}

.badge-running {
    background-color: #0d6efd;
}

.badge-queued {
    background-color: #6c757d;
}

.badge-failed {
    background-color: #dc3545;
}

.alert-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Dataset Table Preview */
.table-preview-btn {
    text-align: left;
    transition: all 0.2s ease;
}

.table-preview-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-preview-btn.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

/* ============================================
   UM DRAFT REVIEW STYLES
   ============================================ */
.stat-card {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background-color: #ffffff;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--bs-primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--bs-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Column chip styling for UM destinations */
.column-chip {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Destination card styling */
.destination-card {
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.destination-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.destination-card .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

/* Coverage progress styling */
.coverage-progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
    overflow: hidden;
}

.coverage-progress .progress-bar {
    transition: width 0.5s ease;
}

/* Advanced details accordion */
.advanced-details .accordion-button {
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.advanced-details .accordion-button:not(.collapsed) {
    background-color: #f8f9fa;
    color: var(--bs-primary);
}

.advanced-details .table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.advanced-details .table th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #dee2e6;
}

.advanced-details .badge {
    font-size: 0.7rem;
}

/* Collapsible sections */
.collapse-toggle {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

.collapse-toggle:hover {
    color: var(--bs-primary);
    text-decoration: none;
}

.collapse-toggle i {
    transition: transform 0.2s ease;
}

/* Relationship mini-graph styles */
.relationship-graph {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
}

.relationship-graph code {
    background-color: #f8f9fa;
    color: var(--bs-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
}

/* Warning and info alerts in UM Review */
.um-review .alert {
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
}

.um-review .alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.um-review .alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Button styling for UM Review actions */
.um-review .btn {
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.um-review .btn:hover {
    transform: translateY(-1px);
}

/* Table styling for dropped columns */
.dropped-columns-table {
    font-size: 0.85rem;
}

.dropped-columns-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

.dropped-columns-table code {
    font-size: 0.8rem;
    background-color: #f8f9fa;
    color: var(--bs-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
}

/* Expression Editor Styling */
.expression-editor-container {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #ffffff;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.expression-editor-container .cm-editor {
    height: auto;
    min-height: 80px;
    max-height: 300px;
}

.expression-editor-container .cm-scroller {
    overflow: auto;
}

.expression-editor-container .cm-content {
    padding: 8px 0;
}

.expression-editor-container .cm-line {
    padding: 0 8px;
}

/* ============================================
   WORKFLOW DESIGNER - DRAG AND DROP
   ============================================ */
.workflow-step {
    transition: opacity 0.2s ease, border 0.2s ease;
}

.workflow-step.dragging {
    opacity: 0.5;
}

.workflow-step.drag-over {
    border: 2px dashed #0d6efd !important;
    background-color: #e7f1ff !important;
}

.drag-handle {
    cursor: grab;
    color: #6c757d;
    transition: color 0.2s ease;
}

.drag-handle:hover {
    color: #023758;
}

.drag-handle:active {
    cursor: grabbing;
}
