﻿/* ==========================================================================
   Credit Intelligence Module Styles
   Scoped with .credit-app to avoid conflicts with existing styles
   ========================================================================== */

/* CSS Isolation - Normalize box-sizing and prevent global style conflicts */
.credit-app,
.credit-app *,
.credit-app *::before,
.credit-app *::after {
    box-sizing: border-box;
}

/* Reset and variables — single .credit-app block */
.credit-app {
    /* CSS Variables */
    --ci-primary: #4f46e5;
    --ci-primary-light: #e0e7ff;
    --ci-bg-body: #f1f5f9;
    --ci-border: #e2e8f0;
    --ci-text-main: #0f172a;
    --ci-text-muted: #64748b;
    --ci-danger-bg: #fee2e2;
    --ci-success-bg: #d1fae5;

    /* Prevent inherited text properties from global styles */
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    word-spacing: normal;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
    line-height: 1.5;

    /* Base appearance */
    font-family: 'Inter', sans-serif;
    background-color: var(--ci-bg-body);
    color: var(--ci-text-main);
    margin: -0.5rem; /* Fallback offset for Radzen body padding */
    padding: 0.5rem;
    overflow-x: hidden;
    min-height: 100vh;
    width: 100%;
}

/* Override Radzen body padding when inside credit-app */
.rz-body:has(.credit-app) {
    padding: 0.5rem;
}

/* Prevent nested credit-app from causing layout issues */
.credit-app .credit-app {
    margin: 0;
    padding: 0;
    min-height: auto;
    background-color: transparent;
}

/* Ensure proper width inheritance for key elements */
.credit-app .tabs-container,
.credit-app #main-content-area {
    width: auto;
    min-width: 0;
}

.credit-app .tabs-container {
    border-bottom: 1px solid var(--ci-border);
    margin-bottom: 16px;
    display: flex;
    gap: 4px;
    padding-left: 4px;
    flex-wrap: wrap;
    overflow: hidden;
}

.credit-app .tabs-container .tab-btn {
    background: none;
    border: none;
    padding: 10px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ci-text-muted);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s;
    flex: 0 1 auto;
    text-align: center;
}

.credit-app .tabs-container .tab-btn:hover {
    color: var(--ci-primary);
}

.credit-app .tabs-container .tab-btn.active {
    color: var(--ci-primary);
    font-weight: 600;
}

.credit-app .tabs-container .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--ci-primary);
}

.credit-app #main-content-area {
    min-height: 400px;
}

.credit-app .fade-in {
    animation: ci-fadeIn 0.3s ease-out;
}

@keyframes ci-fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pills */
.credit-app .pill {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.credit-app .pill-blue {
    background: var(--ci-primary-light);
    color: var(--ci-primary);
}

.credit-app .pill-gray {
    background: #f1f5f9;
    color: #475569;
}

.credit-app .pill-red {
    background: var(--ci-danger-bg);
    color: #991b1b;
}

.credit-app .pill-green {
    background: var(--ci-success-bg);
    color: #065f46;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .credit-app .tabs-container {
        gap: 16px;
        margin-bottom: 20px;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .credit-app .tab-btn {
        font-size: 0.875rem;
        padding: 10px 4px;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    .credit-app .tabs-container {
        gap: 12px;
    }

    .credit-app .tab-btn {
        font-size: 0.8rem;
        padding: 8px 4px;
    }
}

@media (max-width: 360px) {
    .credit-app #main-content-area [role="region"].saas-card-padded .flex.justify-between,
    .credit-app #main-content-area [role="region"].bg-white .flex.justify-between {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.35rem 0.5rem;
    }

    .credit-app #main-content-area [role="region"].saas-card-padded .flex.justify-between > :first-child,
    .credit-app #main-content-area [role="region"].saas-card-padded .flex.justify-between > :last-child,
    .credit-app #main-content-area [role="region"].bg-white .flex.justify-between > :first-child,
    .credit-app #main-content-area [role="region"].bg-white .flex.justify-between > :last-child {
        min-width: 0;
        flex: 1 1 100%;
        overflow-wrap: anywhere;
    }

    .credit-app #main-content-area [role="region"].saas-card-padded .tabular-nums,
    .credit-app #main-content-area [role="region"].bg-white .tabular-nums {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* ==========================================================================
   Flyout Panel Styles
   ========================================================================== */

/* Fix: .rz-body has transform:translateZ(0) which creates a stacking context
   at z-index auto (0). The sidebar sits at z-index:2 as a grid sibling,
   so everything inside .rz-body is trapped below it. Elevate the body
   stacking context only while a flyout is open. */
.rz-layout .rz-body:has(.flyout-overlay.open) {
    z-index: 10102;
}

.credit-app .flyout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.credit-app .flyout-overlay.open {
    opacity: 1;
    visibility: visible;
}

.credit-app .flyout-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(900px, 90vw);
    max-height: 90vh;
    background: white;
    z-index: 10001;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transform: translate(-50%, calc(-50% - 30px));
    border-radius: 18px;
}

.credit-app .flyout-panel.open {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, -50%);
}

.credit-app .flyout-header {
    padding: 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.credit-app .flyout-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 5px 0 0 0;
}

.credit-app .flyout-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.credit-app .flyout-close-btn {
    border: none;
    background: none;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    color: #64748b;
    border-radius: 0.375rem;
    transition: color 0.15s;
}

.credit-app .flyout-close-btn:hover {
    color: #0f172a;
}

.credit-app .flyout-close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #4f46e5;
}

/* Flyout Responsive */
@media (max-width: 768px) {
    .credit-app .flyout-panel {
        width: 96vw;
        max-height: 92vh;
    }

    .credit-app .flyout-header {
        padding: 16px;
    }

    .credit-app .flyout-body {
        padding: 16px;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .credit-app .flyout-panel {
        width: 60vw;
    }
}

/* Full-screen flyout variant */
.credit-app .flyout-panel.fullscreen {
    /* Override base slide-in positioning completely */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: auto;
    margin: 16px;
    border-radius: 16px;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

.credit-app .flyout-panel.fullscreen.open {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* Fullscreen header: sticky tabs row */
.credit-app .flyout-panel.fullscreen .flyout-header {
    padding: 20px 28px;
}

.credit-app .flyout-panel.fullscreen .flyout-body {
    padding: 28px;
}

/* Mobile: fill entire viewport */
@media (max-width: 768px) {
    .credit-app .flyout-panel.fullscreen {
        margin: 0;
        border-radius: 0;
    }

    .credit-app .flyout-panel.fullscreen .flyout-header {
        padding: 14px 16px;
    }

    .credit-app .flyout-panel.fullscreen .flyout-body {
        padding: 16px;
    }
}

/* Tablet: slight margin */
@media (min-width: 769px) and (max-width: 1024px) {
    .credit-app .flyout-panel.fullscreen {
        margin: 10px;
        border-radius: 12px;
    }
}

/* ==========================================================================
   Sub-Flyout (stacked on top of main flyout)
   ========================================================================== */
.credit-app .sub-flyout-overlay {
    z-index: 10100;
    background: rgba(15, 23, 42, 0.5);
}

.credit-app .sub-flyout-panel {
    z-index: 10101;
    width: min(850px, 88vw);
    max-height: 85vh;
}

@media (max-width: 768px) {
    .credit-app .sub-flyout-panel {
        width: 96vw;
        max-height: 92vh;
    }
}

/* ==========================================================================
   Photo Carousel (inside anuncio cards)
   ========================================================================== */
.anuncio-carousel {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f1f5f9;
}

.anuncio-carousel-track {
    display: flex;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.anuncio-carousel-track::-webkit-scrollbar {
    display: none;
}

.anuncio-carousel-track img {
    min-width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: cover;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.anuncio-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.85);
    color: #334155;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: background 0.2s;
    z-index: 2;
}

.anuncio-carousel-btn:hover {
    background: rgba(255,255,255,1);
}

.anuncio-carousel-btn.prev {
    left: 8px;
}

.anuncio-carousel-btn.next {
    right: 8px;
}

.anuncio-carousel-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 2;
}

/* ==========================================================================
   Anuncio Clickable Card
   ========================================================================== */
.anuncio-card-clickable {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.15s;
}

.anuncio-card-clickable:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* ==========================================================================
   Reduced Motion — respect user preference
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .credit-app .flyout-panel,
    .credit-app .flyout-overlay,
    .credit-app .fade-in,
    .anuncio-carousel-track,
    .anuncio-card-clickable {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* end of file */

