/* Custom Styling and Theme Enhancements */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

@variant dark (&:where(.dark, .dark *));

:root {
    font-family: 'Plus Jakarta Sans', sans-serif;
    --transition-speed: 0.3s;
}

/* Ensure text-slate-900 has strong readability against light backgrounds */
:root[data-theme="light"] .text-slate-900 {
    color: #0f172a !important;
}

/* Force Reach brand name and username in navbar to be black in light mode */
:root[data-theme="light"] .navbar-reach-text,
:root[data-theme="light"] .navbar-username {
    color: #000000 !important;
}

/* Premium Theme Toggle Switch Styles */
.theme-switch-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 3.2rem;
    height: 1.6rem;
    padding: 0.2rem;
    background-color: #cbd5e1;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] .theme-switch-btn {
    background-color: #0f172a;
    border-color: #1e293b;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.theme-switch-btn:hover {
    border-color: #6366f1;
    transform: scale(1.05);
}

.theme-switch-ball {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 1.1rem;
    height: 1.1rem;
    background-color: #4f46e5;
    border-radius: 9999px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

:root[data-theme="dark"] .theme-switch-ball {
    transform: translateX(1.5rem);
    background-color: #818cf8;
}

/* Premium profile dropdown modal */
#profile-dropdown-modal {
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.3);
}

.profile-pill-btn {
    background-color: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
    transition: all 0.2s ease;
}

:root[data-theme="dark"] .profile-pill-btn {
    background-color: #0f172a !important;
    border: 1px solid #1e293b !important;
    color: #cbd5e1 !important;
}

.profile-pill-btn:hover {
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.12);
}

/* Solid background profile dropdown modal container */
.profile-modal-container {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
}

:root[data-theme="dark"] .profile-modal-container {
    background-color: #0f172a !important;
    border: 1px solid #1e293b !important;
    color: #cbd5e1 !important;
}

:root[data-theme="light"] .profile-modal-container h4 {
    color: #0f172a !important;
}

:root[data-theme="dark"] .profile-modal-container h4 {
    color: #ffffff !important;
}

:root[data-theme="light"] .profile-modal-container p,
:root[data-theme="light"] .profile-modal-container label {
    color: #475569 !important;
}

:root[data-theme="dark"] .profile-modal-container p,
:root[data-theme="dark"] .profile-modal-container label {
    color: #94a3b8 !important;
}

:root[data-theme="light"] .profile-modal-container .border-b {
    border-color: #e2e8f0 !important;
}

:root[data-theme="dark"] .profile-modal-container .border-b {
    border-color: #1e293b !important;
}



.theme-switch-icon-sun {
    color: #d97706;
    font-size: 0.65rem;
    z-index: 10;
    pointer-events: none;
    margin-left: 0.25rem;
    transition: opacity var(--transition-speed);
}

.theme-switch-icon-moon {
    color: #818cf8;
    font-size: 0.65rem;
    z-index: 10;
    pointer-events: none;
    margin-right: 0.25rem;
    transition: opacity var(--transition-speed);
}

:root[data-theme="light"] .theme-switch-icon-sun {
    opacity: 1;
}

:root[data-theme="light"] .theme-switch-icon-moon {
    opacity: 0.4;
}

:root[data-theme="dark"] .theme-switch-icon-sun {
    opacity: 0.4;
}

:root[data-theme="dark"] .theme-switch-icon-moon {
    opacity: 1;
}

/* Light Theme Variables */
:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(226, 232, 240, 0.9);
    --shadow-color: rgba(148, 163, 184, 0.15);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --input-bg: #f1f5f9;
    --input-border: #cbd5e1;
    --input-text: #0f172a;
    --input-placeholder: #94a3b8;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --hover-bg: rgba(99, 102, 241, 0.06);
}

/* Dark Theme Variables */
:root[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #0f172a;
    --bg-tertiary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #1e293b;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(30, 41, 59, 0.8);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --primary-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    --input-bg: #0f172a;
    --input-border: #1e293b;
    --input-text: #f8fafc;
    --input-placeholder: #475569;
    --card-bg: #0f172a;
    --card-border: #1e293b;
    --hover-bg: rgba(99, 102, 241, 0.08);
}

body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary);
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* ============================================
   LIGHT MODE OVERRIDES
   Override Tailwind's hardcoded dark classes
   ============================================ */

/* Body & page backgrounds */
:root[data-theme="light"] body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Main background overrides (bg-slate-950, bg-slate-900) */
:root[data-theme="light"] .bg-slate-950,
:root[data-theme="light"] .bg-slate-900 {
    background-color: var(--bg-tertiary) !important;
}

/* Card/panel inner backgrounds */
:root[data-theme="light"] .bg-slate-900\/10,
:root[data-theme="light"] .bg-slate-900\/30,
:root[data-theme="light"] .bg-slate-900\/40 {
    background-color: rgba(241, 245, 249, 0.6) !important;
}

/* Opacity-based slate background overrides for light mode */
:root[data-theme="light"] [class^="bg-slate-950/"],
:root[data-theme="light"] [class*=" bg-slate-950/"],
:root[data-theme="light"] [class^="bg-slate-900/"],
:root[data-theme="light"] [class*=" bg-slate-900/"],
:root[data-theme="light"] [class^="bg-slate-850/"],
:root[data-theme="light"] [class*=" bg-slate-850/"],
:root[data-theme="light"] [class^="bg-slate-800/"],
:root[data-theme="light"] [class*=" bg-slate-800/"] {
    background-color: var(--bg-tertiary) !important;
}

/* Prevent text-white override on elements with colored backgrounds or inside them to ensure white text remains readable */
:root[data-theme="light"] .bg-indigo-500.text-white,
:root[data-theme="light"] .bg-indigo-500 .text-white,
:root[data-theme="light"] .bg-indigo-600.text-white,
:root[data-theme="light"] .bg-indigo-600 .text-white,
:root[data-theme="light"] .bg-indigo-700.text-white,
:root[data-theme="light"] .bg-indigo-700 .text-white,
:root[data-theme="light"] .bg-violet-500.text-white,
:root[data-theme="light"] .bg-violet-500 .text-white,
:root[data-theme="light"] .bg-violet-600.text-white,
:root[data-theme="light"] .bg-violet-600 .text-white,
:root[data-theme="light"] .bg-blue-500.text-white,
:root[data-theme="light"] .bg-blue-500 .text-white,
:root[data-theme="light"] .bg-blue-600.text-white,
:root[data-theme="light"] .bg-blue-600 .text-white,
:root[data-theme="light"] .bg-emerald-500.text-white,
:root[data-theme="light"] .bg-emerald-500 .text-white,
:root[data-theme="light"] .bg-emerald-600.text-white,
:root[data-theme="light"] .bg-emerald-600 .text-white,
:root[data-theme="light"] .bg-red-500.text-white,
:root[data-theme="light"] .bg-red-500 .text-white,
:root[data-theme="light"] .bg-red-600.text-white,
:root[data-theme="light"] .bg-red-600 .text-white,
:root[data-theme="light"] .btn-primary.text-white,
:root[data-theme="light"] .btn-primary .text-white,
:root[data-theme="light"] .sidebar-active.text-white,
:root[data-theme="light"] .sidebar-active .text-white,
:root[data-theme="light"] #promo-banner,
:root[data-theme="light"] #promo-banner a:not(:hover) {
    color: #ffffff !important;
}

/* Text overrides */
:root[data-theme="light"] .text-white {
    color: var(--text-primary) !important;
}

:root[data-theme="light"] .text-slate-100,
:root[data-theme="light"] .text-slate-200,
:root[data-theme="light"] .text-slate-300 {
    color: #334155 !important;
}

:root[data-theme="light"] .text-slate-400,
:root[data-theme="light"] .text-slate-350,
:root[data-theme="light"] .text-slate-355 {
    color: #64748b !important;
}

:root[data-theme="light"] .text-slate-500 {
    color: #64748b !important;
}

:root[data-theme="light"] .text-slate-550 {
    color: #94a3b8 !important;
}

/* Visual Editor Tabs and Device Switcher custom overrides */
:root[data-theme="light"] .flex.border-b.bg-slate-950\/40 {
    background-color: var(--bg-secondary) !important;
}

:root[data-theme="light"] .flex.items-center.space-x-2.bg-slate-950\/80 {
    background-color: var(--bg-secondary) !important;
}

/* Inactive device switcher buttons */
:root[data-theme="light"] #btn-desktop:not(.bg-indigo-500),
:root[data-theme="light"] #btn-mobile:not(.bg-indigo-500) {
    color: #64748b !important;
    background-color: transparent !important;
}
:root[data-theme="light"] #btn-desktop:not(.bg-indigo-500):hover,
:root[data-theme="light"] #btn-mobile:not(.bg-indigo-500):hover {
    color: var(--text-primary) !important;
    background-color: var(--bg-tertiary) !important;
}

/* Active device switcher buttons */
:root[data-theme="light"] #btn-desktop.bg-indigo-500,
:root[data-theme="light"] #btn-mobile.bg-indigo-500 {
    color: #ffffff !important;
    background-color: #6366f1 !important;
}

/* Navigation Tabs in light mode */
:root[data-theme="light"] #tab-predefined,
:root[data-theme="light"] #tab-alltenant,
:root[data-theme="light"] #tab-mycustom {
    border-bottom-color: transparent !important;
}

:root[data-theme="light"] #tab-predefined.text-indigo-400,
:root[data-theme="light"] #tab-alltenant.text-indigo-400,
:root[data-theme="light"] #tab-mycustom.text-indigo-400 {
    color: #4f46e5 !important;
    border-bottom-color: #4f46e5 !important;
}

:root[data-theme="light"] #tab-predefined:not(.text-indigo-400),
:root[data-theme="light"] #tab-alltenant:not(.text-indigo-400),
:root[data-theme="light"] #tab-mycustom:not(.text-indigo-400) {
    color: #64748b !important;
}

:root[data-theme="light"] #tab-predefined:not(.text-indigo-400):hover,
:root[data-theme="light"] #tab-alltenant:not(.text-indigo-400):hover,
:root[data-theme="light"] #tab-mycustom:not(.text-indigo-400):hover {
    color: #0f172a !important;
    background-color: var(--bg-tertiary) !important;
}

/* Border overrides */
:root[data-theme="light"] .border-slate-800,
:root[data-theme="light"] .border-slate-850,
:root[data-theme="light"] .border-slate-800\/50,
:root[data-theme="light"] .border-slate-800\/80 {
    border-color: var(--border-color) !important;
}

:root[data-theme="light"] .border-slate-900 {
    border-color: #e2e8f0 !important;
}

/* Input fields */
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

:root[data-theme="light"] input::placeholder,
:root[data-theme="light"] textarea::placeholder {
    color: var(--input-placeholder) !important;
}

/* Sidebar & interactive backgrounds */
:root[data-theme="light"] .bg-slate-800 {
    background-color: #e2e8f0 !important;
}

:root[data-theme="light"] .bg-slate-800:hover,
:root[data-theme="light"] .hover\:bg-slate-700:hover {
    background-color: #cbd5e1 !important;
}

:root[data-theme="light"] .bg-slate-800\/40,
:root[data-theme="light"] .hover\:bg-slate-800\/40:hover {
    background-color: rgba(226, 232, 240, 0.5) !important;
}

/* Tables */
:root[data-theme="light"] table th {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}

:root[data-theme="light"] table td {
    border-color: #f1f5f9 !important;
}

:root[data-theme="light"] table tr:hover {
    background-color: rgba(99, 102, 241, 0.04) !important;
}

/* ============================================ */


/* Glassmorphism Styles */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--shadow-color);
    transition: background var(--transition-speed), border-color var(--transition-speed);
}

.glass-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px 0 var(--shadow-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color var(--transition-speed), background var(--transition-speed);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px 0 var(--shadow-color);
    border-color: #6366f1;
}

/* Smooth custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}

/* Micro animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Gradients text */
.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Button style overrides */
.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff !important;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Sidebar Active State indicator */
.sidebar-active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0) 100%);
    border-left: 4px solid #6366f1;
    color: #6366f1 !important;
}

/* Steps Indicator for Wizards */
.step-dot.active {
    background-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.step-line.active {
    background-color: #6366f1;
}

/* Light mode specific badge/pill overrides to preserve readability */
:root[data-theme="light"] .bg-indigo-500\/10 {
    background-color: rgba(99, 102, 241, 0.08) !important;
}

:root[data-theme="light"] .bg-red-500\/10 {
    background-color: rgba(239, 68, 68, 0.08) !important;
}

:root[data-theme="light"] .bg-amber-500\/10 {
    background-color: rgba(245, 158, 11, 0.08) !important;
}

:root[data-theme="light"] .bg-purple-500\/10 {
    background-color: rgba(168, 85, 247, 0.08) !important;
}

:root[data-theme="light"] .bg-blue-500\/10 {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

:root[data-theme="light"] .bg-emerald-500\/10 {
    background-color: rgba(16, 185, 129, 0.08) !important;
}

/* Keep colored text legible in light mode */
:root[data-theme="light"] .text-indigo-400,
:root[data-theme="light"] .text-indigo-500 {
    color: #4f46e5 !important;
}

:root[data-theme="light"] .text-red-400 {
    color: #dc2626 !important;
}

:root[data-theme="light"] .text-amber-400 {
    color: #d97706 !important;
}

:root[data-theme="light"] .text-purple-400 {
    color: #9333ea !important;
}

:root[data-theme="light"] .text-blue-400 {
    color: #2563eb !important;
}

:root[data-theme="light"] .text-emerald-400,
:root[data-theme="light"] .text-emerald-500 {
    color: #059669 !important;
}

:root[data-theme="light"] .text-rose-500 {
    color: #e11d48 !important;
}

/* HTML Visual Builder Styles */
.visual-block-wrapper {
    position: relative;
    border: 2px dashed transparent;
    transition: all 0.2s ease;
}

.visual-block-wrapper:hover {
    border-color: #6366f1;
    background-color: rgba(99, 102, 241, 0.02);
}

.visual-block-active {
    border: 2px solid #6366f1 !important;
    background-color: rgba(99, 102, 241, 0.05) !important;
}

.visual-block-actions {
    display: none;
}

.visual-block-wrapper:hover .visual-block-actions {
    display: flex;
}

/* Device Viewport Frames */
.preview-device-mobile {
    max-width: 375px !important;
    border: 12px solid #1e293b !important;
    border-radius: 36px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}