/* =========================================
   1. GLOBAL & LAYOUT STYLES
   ========================================= */

:root {
    /* Light Theme Variables */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-secondary: #f1f5f9;
    --bg-surface-hover: #f8fafc;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-focus: #6366f1;
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --card-hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-secondary: #334155;
    --bg-surface-hover: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    
    --border-color: #334155;
    --border-focus: #818cf8;
    
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --card-hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    
    --input-bg: #1e293b;
    --input-border: #475569;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

main {
    flex: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-secondary) !important;
}

.ls-1 {
    letter-spacing: 0.05em;
}

/* =========================================
   2. NAVBAR & HEADER
   ========================================= */

.navbar {
    padding: 0.75rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    background: var(--primary-gradient) !important;
    z-index: 1030;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white !important;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.brand-icon {
    font-size: 1.8rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.nav-link {
    transition: background-color 0.2s ease, color 0.2s ease;
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    margin: 0 0.25rem;
    font-weight: 500;
    color: rgba(255,255,255,0.9) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: white !important;
}

.nav-link i, .nav-link svg {
    font-size: 1.1em;
}

.support-link {
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.2);
}

.support-link:hover {
    background: rgba(255,255,255,0.25) !important;
    border-color: rgba(255,255,255,0.3);
}

/* Theme Toggle */
.btn-theme-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    outline: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.25s;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    padding: 0 !important;
}

.btn-theme-toggle:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.btn-theme-toggle svg {
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    stroke: currentColor;
}

.btn-theme-toggle:active svg {
    transform: rotate(360deg);
}

/* Sticky Navbar */
.navbar.sticky-top {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* =========================================
   3. COMPONENTS & UTILITIES
   ========================================= */

/* Cards */
.card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    transition: var(--transition);
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
}

.card-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    border-radius: 1rem 1rem 0 0 !important;
    padding: 1.5rem;
}

.card-body {
    padding: 1.5rem;
    color: var(--text-primary);
}

.card-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}

.shadow-sm {
    box-shadow: var(--card-shadow) !important;
}

.rounded-4 {
    border-radius: 1rem !important;
}

.hover-scale:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow) !important;
}

.hover-shadow:hover {
    box-shadow: var(--card-shadow) !important;
    background-color: var(--bg-surface-hover);
    border-color: var(--primary-color) !important;
}

/* Icons & Avatars */
.icon-box {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.service-card:hover .icon-box {
    transform: scale(1.1) rotate(5deg);
}

.avatar-placeholder {
    font-weight: 700;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4f46e5;
}

/* Buttons */
.btn {
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

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

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

/* Alerts */
.alert {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 1rem 1.5rem;
    font-weight: 500;
}

/* Forms */
.form-control, .form-select {
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s;
}

.input-group-text {
    background-color: var(--bg-surface-secondary);
    border: 2px solid var(--border-color);
    border-right: none;
    color: var(--text-secondary);
    border-top-left-radius: 0.75rem;
    border-bottom-left-radius: 0.75rem;
}

.input-group .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--border-focus);
    color: var(--text-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   4. PAGE SPECIFIC STYLES
   ========================================= */

/* Hero Section (Landing) */
.hero-section {
    background: var(--primary-gradient);
    color: white;
    border-radius: 1.5rem;
    padding: 4rem 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
    margin-top: 2rem;
}

/* Fix for buttons inside Hero Section */
.hero-section .btn-primary {
    background: white;
    color: var(--primary-color);
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative; /* Ensure buttons are above the background */
    z-index: 2;
}

.hero-section .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    background: #f8fafc;
    color: var(--primary-hover);
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: rotate 30s linear infinite;
    pointer-events: none; /* This allows clicks to pass through the animation layer */
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Chat Specifics */
.ai-chat-container {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
}

.shadow-inner {
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

/* Canvas */
#natalCanvas {
    filter: drop-shadow(0 0 10px rgba(78, 204, 163, 0.2));
}

/* Pricing Cards */
.pricing-card {
    border: 1px solid var(--border-color) !important;
    overflow: visible !important;
    background-color: var(--bg-surface);
}

.pricing-card .card-header {
    padding-top: 2rem !important;
    padding-bottom: 1.5rem !important;
    border-bottom: none;
}

/* Ensure pricing card headers inherit text color (for white/dark text utilities) */
.pricing-card .card-header h1,
.pricing-card .card-header h2,
.pricing-card .card-header h3,
.pricing-card .card-header h4,
.pricing-card .card-header h5,
.pricing-card .card-header h6 {
    color: inherit !important;
}

.popular-badge-wrapper {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.popular-badge {
    border: 2px solid #ffc107 !important;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.5) !important;
}

/* Utilities */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.transition-all {
    transition: all 0.3s ease;
}

/* Footer */
footer {
    margin-top: auto;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    color: white;
    border-top: none;
    padding: 2rem 0;
}

[data-theme="dark"] footer {
    background: linear-gradient(135deg, #0f172a 0%, #020617 100%) !important;
    border-top: 1px solid #1e293b;
}

/* Override some Bootstrap Utils for Theme Compatibility */
.bg-light {
    background-color: var(--bg-surface-secondary) !important;
}

.bg-white {
    background-color: var(--bg-surface) !important;
}

.text-dark {
    color: var(--text-primary) !important;
}

/* Dark Mode Subtle Backgrounds Overrides */
[data-theme="dark"] .bg-primary-subtle { background-color: rgba(99, 102, 241, 0.2) !important; color: #a5b4fc !important; }
[data-theme="dark"] .bg-success-subtle { background-color: rgba(34, 197, 94, 0.2) !important; color: #86efac !important; }
[data-theme="dark"] .bg-info-subtle { background-color: rgba(6, 182, 212, 0.2) !important; color: #67e8f9 !important; }
[data-theme="dark"] .bg-warning-subtle { background-color: rgba(234, 179, 8, 0.2) !important; color: #fde047 !important; }
[data-theme="dark"] .bg-danger-subtle { background-color: rgba(239, 68, 68, 0.2) !important; color: #fca5a5 !important; }
[data-theme="dark"] .bg-secondary-subtle { background-color: rgba(148, 163, 184, 0.2) !important; color: #cbd5e1 !important; }

/* Text Emphasis Overrides for Dark Mode */
[data-theme="dark"] .text-primary { color: #818cf8 !important; }
[data-theme="dark"] .text-success { color: #4ade80 !important; }
[data-theme="dark"] .text-info { color: #22d3ee !important; }
[data-theme="dark"] .text-warning { color: #facc15 !important; }
[data-theme="dark"] .text-danger { color: #f87171 !important; }
[data-theme="dark"] .text-secondary { color: #94a3b8 !important; }

/* Force border on cards in dark mode even if border-0 is used, for better separation */
[data-theme="dark"] .card.border-0 {
    border: 1px solid var(--border-color) !important;
}

/* List Group */
.list-group-item {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Modals */
.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-header .modal-title {
    color: inherit;
}

.modal-footer {
    border-top-color: var(--border-color);
}

.btn-close {
    filter: invert(0);
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 1;
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .hero-section {
        padding: 2.5rem 1rem;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
    
    .card-body {
        padding: 1.25rem;
    }
}
