/* assets/css/portal.css */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* Prevent Flash of Uninjected Layout (FOUL) */
/* Hide the main content while it is a direct child of the body (before injection) */
body:not(.layout-ready)>main,
body:not(.layout-ready) #layout-wrapper {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Smooth reveal once ready */
#layout-wrapper {
    opacity: 0;
    transform: scale(0.98) translateY(10px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

body.layout-ready #layout-wrapper {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Page Transition: Fade out on navigation */
body.page-leaving #layout-wrapper {
    opacity: 0;
    transform: scale(0.99) translateY(-5px);
    transition: opacity 0.3s ease-in, transform 0.3s ease-in;
}

/* Ensure portal content stays visible once moved */
#portal-content main {
    opacity: 1 !important;
    pointer-events: auto !important;
}

:root {
    --primary: #52ba71;
    /* Refined Brevo Green */
    --primary-hover: #45a463;
    --primary-soft: #f0fdf4;
    --bg-main: #f8fafc;
    /* Cool bluish white background */
    --bg-side: #edffef;
    /* Soft greenish tint for sidebar */
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-main: #1e293b;
    /* Dark slate text */
    --text-muted: #64748b;
    --border: #e2e8f0;
    --header-bg: rgba(255, 255, 255, 0.8);
    --glass-bg: rgba(248, 250, 252, 0.8);
    --accent-purple: #7451eb;
    /* Brevo purple accent */
    --portal-gradient: linear-gradient(to right, #eff6ff, #f5f3ff);
}

body.dark-theme {
    --primary: #00ff88;
    --primary-hover: #34d399;
    --primary-soft: rgba(0, 255, 136, 0.1);
    --bg-main: #0a1a0f;
    --bg-side: #0f2419;
    --bg-card: #162c21;
    --bg-input: #1a2e23;
    --text-main: #d1e7d1;
    --text-muted: #88a691;
    --border: rgba(0, 255, 136, 0.15);
    --header-bg: #0a1a0f;
    --glass-bg: rgba(15, 36, 25, 0.8);
    --portal-gradient: linear-gradient(to right, rgba(15, 36, 25, 0.9), rgba(0, 255, 136, 0.05));
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
}

/* Custom styles for dashboard cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* Premium Skeleton Loader */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #f1f2f4 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 1400px 100%;
    animation-duration: 3.5s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;
    animation-name: shimmer;
    border-radius: 4px;
    opacity: 0.6;
}

body.dark-theme .skeleton {
    background: #1a2e23;
    background-image: linear-gradient(to right, #1a2e23 0%, #173223 20%, #1a2e23 40%, #1a2e23 100%);
    opacity: 0.4;
}

.skeleton-text {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.btn-primary {
    background-color: var(--primary);
    color: #0a0a0a;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(82, 186, 113, 0.2);
}

/* Premium Segmented Controls (Tabs) */
.tab-container {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 6px;
    background: var(--bg-side);
    border-radius: 14px;
    border: 1px solid var(--border);
    scrollbar-width: none;
    /* Firefox */
}

.tab-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.tab-btn {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-radius: 10px;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tab-btn:hover:not(.active) {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.03);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tab-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(100, 116, 139, 0.05);
    transition: all 0.2s;
}

.tab-btn.active .tab-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

body.dark-theme .tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .tab-btn.active {
    background: var(--bg-input);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}


.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
}

body.dark-theme .btn-secondary {
    background-color: var(--bg-input);
    border-color: rgba(0, 255, 136, 0.3);
}

body.dark-theme .btn-secondary:hover {
    background-color: var(--bg-side);
    border-color: var(--primary);
}

.nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Premium Banners & Page Headers */
.page-header-banner {
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
}

.info-banner-premium {
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.info-banner-premium::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: var(--primary-soft);
    border-radius: 50%;
    mask-image: radial-gradient(circle, #000 60%, transparent 100%);
    pointer-events: none;
}

/* Report Paywall & Sheet Navigation */
.report-sheet-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-side);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    width: 100%;
}

.report-sheet-nav::-webkit-scrollbar {
    height: 4px;
}

.report-sheet-nav::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.sheet-tab {
    flex: 0 0 auto;
    /* Force no-shrink */
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.sheet-tab:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

.sheet-tab.active {
    background: var(--primary);
    color: #0a0a0a !important;
    border-color: var(--primary);
}

.sheet-tab.locked::after {
    content: '\f023';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 6px;
    font-size: 9px;
    opacity: 0.7;
}

.paywall-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.paywall-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 32px;
    text-align: center;
    max-width: 360px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.paywall-lock-icon {
    width: 64px;
    height: 64px;
    background: var(--primary-soft);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.paywall-lock-icon i {
    font-size: 24px;
    color: var(--primary);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


.banner-icon-container {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary);
    color: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(82, 186, 113, 0.2);
}

.banner-content h3 {
    font-weight: 700;
    color: var(--text-main);
    font-size: 14px;
    margin-bottom: 4px;
}

.banner-content p {
    font-size: 12px;
    color: var(--text-main);
    line-height: 1.6;
}

.nav-active {
    background-color: var(--primary) !important;
    color: #1a1a1a !important;
    box-shadow: 0 10px 15px -3px rgba(45, 245, 109, 0.2), 0 4px 6px -2px rgba(45, 245, 109, 0.1);
}

body.dark-theme .nav-active {
    color: #0a1a0f !important;
    box-shadow: 0 10px 25px -5px rgba(0, 255, 136, 0.3);
}

.input-field {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 12px 16px;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    font-family: 'Inter', sans-serif;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.input-field.input-error {
    border-color: #ef4444 !important;
    background-color: #fef2f2;
}

.dark-theme .input-field.input-error {
    background-color: rgba(239, 68, 68, 0.05);
}

.input-field.input-error:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.error-message {
    color: #ef4444;
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
    display: block;
    animation: slideInDown 0.2s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Validation & Feedback */
.required-star {
    color: #ef4444;
    margin-left: 2px;
}

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1), toast-out 0.4s 4.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
}

@keyframes toast-in {
    from {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    to {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }
}

.toast::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    width: 100%;
    animation: toast-progress 5s linear forwards;
}

@keyframes toast-progress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.toast.error::before {
    background: #ef4444;
}

.toast.success::before {
    background: var(--primary);
}

.toast.warning::before {
    background: #f59e0b;
}

.toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.toast.error .toast-icon {
    background: #fee2e2;
    color: #ef4444;
}

.toast.warning .toast-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Global Theme Overrides for hardcoded Tailwind classes */
body.dark-theme .bg-white {
    background-color: var(--bg-card) !important;
}

body.dark-theme .bg-slate-50 {
    background-color: var(--bg-side) !important;
}

body.dark-theme .bg-slate-50\/50 {
    background-color: rgba(15, 36, 25, 0.5) !important;
}

body.dark-theme .bg-slate-100 {
    background-color: var(--bg-input) !important;
}

body.dark-theme .bg-slate-100\/30 {
    background-color: rgba(26, 46, 35, 0.3) !important;
}

body.dark-theme .text-\[\#0a0a0a\],
body.dark-theme .text-slate-900,
body.dark-theme .text-slate-800,
body.dark-theme .text-slate-700 {
    color: var(--text-main) !important;
}

body.dark-theme .text-slate-500,
body.dark-theme .text-slate-600,
body.dark-theme .text-slate-400 {
    color: var(--text-muted) !important;
}

body.dark-theme .text-blue-700,
body.dark-theme .text-blue-600 {
    color: var(--primary) !important;
}

/* Better Selection and Hover in Dark Mode */
body.dark-theme .hover\:bg-white:hover,
body.dark-theme .hover\:bg-slate-50:hover,
body.dark-theme .group:hover .group-hover\:bg-slate-50 {
    background-color: var(--bg-side) !important;
}

/* Demo Read-Only Constraints (v3.5.8) */
body.demo-read-only-ui .btn-primary:not([onclick*="export"]):not([onclick*="Report"]):not([onclick*="report"]):not([onclick*="download"]),
body.demo-read-only-ui a.btn-primary:not([href*="reporting"]),
body.demo-read-only-ui button[onclick*="openModal"],
body.demo-read-only-ui button[onclick*="checkAndOpenModal"],
body.demo-read-only-ui a[href*="add.html"],
body.demo-read-only-ui .fa-trash,
body.demo-read-only-ui .fa-trash-alt,
body.demo-read-only-ui button[onclick*="delete"],
body.demo-read-only-ui button[id*="delete"],
body.demo-read-only-ui #delete-btn,
body.demo-read-only-ui #empty-state a[href*="add.html"] {
    display: none !important;
}

/* Adjust Action Column Layout when delete is hidden */
body.demo-read-only-ui .text-right.flex.justify-end.gap-2 {
    justify-content: center !important;
}

body.demo-read-only-ui .fa-edit {
    color: var(--primary) !important;
}

body.demo-read-only-ui .fa-edit::before {
    content: "\f06e" !important; /* fa-eye */
}

body.dark-theme .border-slate-50,
body.dark-theme .border-slate-100,
body.dark-theme .border-slate-200,
body.dark-theme .divide-slate-50>*+*,
body.dark-theme .divide-slate-100>*+* {
    border-color: var(--border) !important;
}

/* Fix th color visibility in dark mode if it's hardcoded to #0a0a0a */
body.dark-theme th.text-\[\#0a0a0a\],
body.dark-theme td.text-\[\#0a0a0a\],
body.dark-theme h2.text-\[\#0a0a0a\],
body.dark-theme h3.text-\[\#0a0a0a\],
body.dark-theme h4.text-\[\#0a0a0a\] {
    color: var(--text-main) !important;
}

body.dark-theme .bg-gray-100,
body.dark-theme .bg-slate-50,
body.dark-theme .bg-emerald-50,
body.dark-theme .bg-amber-50,
body.dark-theme .bg-red-50 {
    background-color: var(--bg-side) !important;
}

body.dark-theme .bg-gray-100 {
    color: var(--text-muted) !important;
}

body.dark-theme select option {
    background-color: var(--bg-input);
    color: var(--text-main);
}

/* Theme-aware Gradients */
.bg-portal-gradient {
    background: var(--portal-gradient);
}

/* Global Theme Overrides for hardcoded Tailwind classes (Continued) */
body.dark-theme .bg-blue-50 {
    background-color: var(--bg-side) !important;
}

body.dark-theme .bg-blue-50\/50 {
    background-color: rgba(15, 36, 25, 0.5) !important;
}

body.dark-theme .bg-emerald-100 {
    background-color: rgba(16, 185, 129, 0.1) !important;
    color: #34d399 !important;
}

body.dark-theme .bg-amber-100 {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: #fbbf24 !important;
}

body.dark-theme .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
}

body.dark-theme .border-l-4.border-\[var\(--primary\)\] {
    border-left-width: 4px !important;
    border-left-color: var(--primary) !important;
}

/* Modal and Overlays */
body.dark-theme .bg-slate-900\/40,
body.dark-theme .bg-black\/50 {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-side);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Fix for specific elements */
.nav-link.active {
    background-color: var(--primary) !important;
    color: #000000 !important;
}