/* ============================================
   NEBULA THEME - Rocket + Espacio Vivo
   ============================================ */

/* === Google Font === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* === CSS Variables === */
:root {
    --nebula-primary: #7B55C3;
    --nebula-primary-light: #9B7BD4;
    --nebula-primary-dark: #5E3BA0;
    --nebula-accent: #FF6FAF;
    --nebula-accent-light: #FF8FC3;
    --nebula-dark-bg: #1a1a2e;
    --nebula-sidebar-hover: #16213e;
    --nebula-text-light: #e0e0e0;
    --nebula-success: #00d4aa;
    --nebula-warning: #ffa726;
    --nebula-danger: #ef5350;
    --nebula-info: #42a5f5;
    --nebula-card-radius: 12px;
    --nebula-card-shadow: 0 2px 12px rgba(123, 85, 195, 0.08);
    --nebula-card-shadow-hover: 0 4px 20px rgba(123, 85, 195, 0.15);
}

/* === Base Typography === */
body, .body-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Sidebar === */
.left-sidebar,
aside.left-sidebar {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f0c29 100%) !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link {
    color: var(--nebula-text-light) !important;
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.2s ease;
}

.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link:hover,
.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link.active {
    background: var(--nebula-sidebar-hover) !important;
    color: #fff !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link.active {
    background: linear-gradient(135deg, var(--nebula-primary) 0%, var(--nebula-primary-dark) 100%) !important;
    box-shadow: 0 2px 8px rgba(123, 85, 195, 0.3);
}

.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link i,
.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link .hide-menu {
    color: var(--nebula-text-light) !important;
}

.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link:hover i,
.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link:hover .hide-menu,
.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link.active i,
.left-sidebar .sidebar-nav ul .sidebar-item .sidebar-link.active .hide-menu {
    color: #fff !important;
}

/* Sidebar brand/logo area */
.left-sidebar .brand-logo,
.left-sidebar .scroll-sidebar {
    background: transparent !important;
}

/* === Top Navbar === */
.topbar, header.app-header {
    background: #fff !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* === Buttons === */
.btn-primary {
    background: var(--nebula-primary) !important;
    border-color: var(--nebula-primary) !important;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--nebula-primary-light) !important;
    border-color: var(--nebula-primary-light) !important;
    box-shadow: 0 4px 12px rgba(123, 85, 195, 0.3);
}

.btn-success {
    background: var(--nebula-success) !important;
    border-color: var(--nebula-success) !important;
    border-radius: 8px;
}

.btn-warning {
    background: var(--nebula-warning) !important;
    border-color: var(--nebula-warning) !important;
    border-radius: 8px;
    color: #fff !important;
}

.btn-danger {
    background: var(--nebula-danger) !important;
    border-color: var(--nebula-danger) !important;
    border-radius: 8px;
}

.btn-info {
    background: var(--nebula-info) !important;
    border-color: var(--nebula-info) !important;
    border-radius: 8px;
    color: #fff !important;
}

.btn-secondary {
    border-radius: 8px;
}

/* === Cards === */
.card {
    border-radius: var(--nebula-card-radius) !important;
    box-shadow: var(--nebula-card-shadow) !important;
    border: none !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.card-header {
    border-radius: var(--nebula-card-radius) var(--nebula-card-radius) 0 0 !important;
    background: transparent !important;
    border-bottom: 1px solid rgba(0,0,0,0.06) !important;
}

/* === Tables === */
.table {
    border-radius: 8px;
    overflow: hidden;
}

.table thead th {
    background: #f8f7fc !important;
    border-bottom: 2px solid var(--nebula-primary) !important;
    color: var(--nebula-primary-dark);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Forms === */
.form-control, .form-select {
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--nebula-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(123, 85, 195, 0.15) !important;
}

/* === Pagination === */
.page-link {
    border-radius: 8px !important;
    margin: 0 2px;
}

.page-item.active .page-link {
    background: var(--nebula-primary) !important;
    border-color: var(--nebula-primary) !important;
}

/* === Badges === */
.badge {
    border-radius: 6px;
    font-weight: 500;
}

.badge.bg-primary, .badge.badge-primary {
    background: var(--nebula-primary) !important;
}

/* === Links === */
a {
    color: var(--nebula-primary);
}

a:hover {
    color: var(--nebula-primary-dark);
}

/* === Dropdowns === */
.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: none;
}

.dropdown-item:hover {
    background: #f8f7fc;
    color: var(--nebula-primary);
}

/* === Login Page === */
body.nebula-login,
.nebula-login-wrapper {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%) !important;
    min-height: 100vh;
}

.nebula-login-card {
    background: rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.nebula-login-card .form-control {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

.nebula-login-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.nebula-login-card .form-control:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: var(--nebula-primary-light) !important;
    box-shadow: 0 0 0 0.2rem rgba(123, 85, 195, 0.25) !important;
}

.nebula-login-card .btn-primary {
    background: linear-gradient(135deg, var(--nebula-primary), var(--nebula-accent)) !important;
    border: none !important;
    border-radius: 10px;
    padding: 10px 24px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nebula-login-card .btn-primary:hover {
    background: linear-gradient(135deg, var(--nebula-primary-light), var(--nebula-accent-light)) !important;
    box-shadow: 0 4px 16px rgba(123, 85, 195, 0.4);
}

.nebula-brand {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--nebula-primary-light), var(--nebula-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 6px;
    text-transform: uppercase;
}

.nebula-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* === Dashboard KPI Cards === */
.nebula-kpi-card {
    border-radius: 16px !important;
    border: none !important;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nebula-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.nebula-kpi-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.nebula-kpi-green {
    background: linear-gradient(135deg, #00d4aa, #00b894) !important;
}

.nebula-kpi-orange {
    background: linear-gradient(135deg, #ffa726, #ff9800) !important;
}

.nebula-kpi-purple {
    background: linear-gradient(135deg, #7B55C3, #5E3BA0) !important;
}

.nebula-kpi-pink {
    background: linear-gradient(135deg, #FF6FAF, #e84393) !important;
}

.nebula-kpi-card .kpi-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.nebula-kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0.25rem 0;
}

.nebula-kpi-card .kpi-label {
    font-size: 0.85rem;
    opacity: 0.85;
    font-weight: 500;
}

/* === Stats section improvements === */
.bg-light {
    background: #f8f7fc !important;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--nebula-primary-light);
    border-radius: 3px;
}

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

/* === Alerts === */
.alert {
    border-radius: 10px;
    border: none;
}

/* === Modal === */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* === Progress bars === */
.progress {
    border-radius: 8px;
    height: 8px;
}

.progress-bar {
    background: var(--nebula-primary);
}

/* === Toast === */
.toast {
    border-radius: 12px;
}

/* === FIX: Header z-index and positioning === */
header.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
}

header.app-header .navbar {
    min-height: 60px;
    padding: 0 1rem;
}

/* Fix: Ensure nav items don't overlap */
header.app-header .navbar-collapse .navbar-nav {
    gap: 0.25rem;
}

header.app-header .navbar-nav .nav-link {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
}

/* Fix: Logo text in header */
header.app-header .logo-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--nebula-primary-dark) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    display: inline-block;
}

/* Fix: body-wrapper margin to not overlap sidebar */
.body-wrapper {
    min-height: 100vh;
}

/* === FIX v2: Search bar and header overlap === */
.body-wrapper {
    position: relative;
}

header.app-header .navbar {
    position: relative;
    z-index: 1030;
    background: #fff !important;
}

/* Ensure page content doesn't overlap header icons */
.body-wrapper > .pt-4 {
    position: relative;
    z-index: 1;
}

/* Fix MegaSearch page - search input should not overlap nav */
#MegaSearchForm,
form[action="MegaSearch"] {
    position: relative;
    z-index: 1;
}

/* Ensure header right icons are always clickable */
header.app-header #navbarNav {
    z-index: 1031;
    position: relative;
}
