/**
 * MeshCore Hub - Custom Application Styles
 *
 * This file contains all custom CSS that extends the Tailwind/DaisyUI framework.
 * Organized in sections:
 * - Color palette
 * - Navbar styling
 * - Scrollbar styling
 * - Table styling
 * - Text utilities
 * - Prose (markdown content) styling
 * - Leaflet map theming
 */

/* ==========================================================================
   Color Palette
   Single source of truth for page/section colors used across nav, charts,
   and page content. All values are OKLCH.
   ========================================================================== */

:root {
    --color-dashboard: oklch(0.75 0.15 210);   /* cyan */
    --color-nodes: oklch(0.65 0.24 265);       /* violet */
    --color-adverts: oklch(0.7 0.17 330);      /* magenta */
    --color-messages: oklch(0.75 0.18 180);    /* teal */
    --color-map: oklch(0.8471 0.199 83.87);      /* yellow (matches btn-warning) */
    --color-members: oklch(0.72 0.17 50);      /* orange */
    --color-neutral: oklch(0.3 0.01 250);     /* subtle dark grey */
}

/* Light mode: darker section colors for contrast on light backgrounds */
[data-theme="light"] {
    --color-dashboard: oklch(0.55 0.15 210);
    --color-nodes: oklch(0.50 0.24 265);
    --color-adverts: oklch(0.55 0.17 330);
    --color-messages: oklch(0.55 0.18 180);
    --color-map: oklch(0.58 0.16 45);
    --color-members: oklch(0.55 0.18 25);
    --color-neutral: oklch(0.85 0.01 250);
}

/* ==========================================================================
   Navbar Styling
   ========================================================================== */

/* Spacing between horizontal nav items */
.menu-horizontal { gap: 0.125rem; }

/* Invert white logos/images to dark for light mode */
[data-theme="light"] .theme-logo {
    filter: brightness(0.15);
}

/* Ensure hero heading is pure black/white per theme */
.hero-title {
    color: #fff;
}
[data-theme="light"] .hero-title {
    color: #000;
}

/* Nav icon colors */
.nav-icon-dashboard { color: var(--color-dashboard); }
.nav-icon-nodes { color: var(--color-nodes); }
.nav-icon-adverts { color: var(--color-adverts); }
.nav-icon-messages { color: var(--color-messages); }
.nav-icon-map { color: var(--color-map); }
.nav-icon-members { color: var(--color-members); }

/* Propagate section color to parent li for hover/active backgrounds */
.navbar .menu li:has(.nav-icon-dashboard) { --nav-color: var(--color-dashboard); }
.navbar .menu li:has(.nav-icon-nodes) { --nav-color: var(--color-nodes); }
.navbar .menu li:has(.nav-icon-adverts) { --nav-color: var(--color-adverts); }
.navbar .menu li:has(.nav-icon-messages) { --nav-color: var(--color-messages); }
.navbar .menu li:has(.nav-icon-map) { --nav-color: var(--color-map); }
.navbar .menu li:has(.nav-icon-members) { --nav-color: var(--color-members); }

/* Section-tinted hover and active backgrounds (!important to override DaisyUI CDN) */
.navbar .menu li > a:hover {
    background-color: color-mix(in oklch, var(--nav-color, oklch(var(--bc))) 12%, transparent) !important;
}
.navbar .menu li > a.active {
    background-color: color-mix(in oklch, var(--nav-color, oklch(var(--bc))) 20%, transparent) !important;
    color: inherit !important;
}

/* Homepage hero buttons: slightly thicker outline, white text on hover */
#app .btn-outline {
    border-width: 2px;
}
#app .btn-outline:hover {
    color: #fff !important;
}

/* ==========================================================================
   Panel Glow
   Radial color glow from bottom-right corner.
   Set --panel-color on the element for a section-tinted glow.
   ========================================================================== */

.panel-glow {
    background-image:
        radial-gradient(
            ellipse at 80% 80%,
            color-mix(in oklch, var(--panel-color, transparent) 15%, transparent),
            transparent 70%
        );
}

.panel-glow.panel-glow-tl {
    background-image:
        radial-gradient(
            ellipse at 20% 20%,
            color-mix(in oklch, var(--panel-color, transparent) 15%, transparent),
            transparent 70%
        );
}

.panel-solid {
    background-color: color-mix(in oklch, var(--panel-color, transparent) 10%, oklch(var(--b1)));
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: oklch(var(--b2));
}

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

::-webkit-scrollbar-thumb:hover {
    background: oklch(var(--bc) / 0.5);
}

/* ==========================================================================
   Table Styling
   ========================================================================== */

.table-compact td,
.table-compact th {
    padding: 0.5rem 0.75rem;
}

/* ==========================================================================
   Text Utilities
   ========================================================================== */

.truncate-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   Prose Styling (Custom Markdown Pages)
   ========================================================================== */

.prose h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.prose h2 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.prose h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.prose h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.prose p {
    margin-bottom: 1rem;
    line-height: 1.75;
}

.prose ul,
.prose ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.prose ul {
    list-style-type: disc;
}

.prose ol {
    list-style-type: decimal;
}

.prose li {
    margin-bottom: 0.25rem;
}

.prose a {
    color: oklch(var(--p));
    text-decoration: underline;
}

.prose a:hover {
    color: oklch(var(--pf));
}

.prose code {
    background: oklch(var(--b2));
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.prose pre {
    background: oklch(var(--b2));
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.prose pre code {
    background: none;
    padding: 0;
}

.prose blockquote {
    border-left: 4px solid oklch(var(--bc) / 0.3);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
}

.prose table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.prose th,
.prose td {
    border: 1px solid oklch(var(--bc) / 0.2);
    padding: 0.5rem;
    text-align: left;
}

.prose th {
    background: oklch(var(--b2));
    font-weight: 600;
}

.prose hr {
    border: none;
    border-top: 1px solid oklch(var(--bc) / 0.2);
    margin: 2rem 0;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}


/* ==========================================================================
   Leaflet Map Theming (Dark Mode)
   ========================================================================== */

/* Popup styling */
.leaflet-popup-content-wrapper {
    background: oklch(var(--b1));
    color: oklch(var(--bc));
}

.leaflet-popup-tip {
    background: oklch(var(--b1));
}

/* Map container defaults */
#map,
#node-map {
    border-radius: var(--rounded-box);
}

#map {
    height: calc(100vh - 350px);
    min-height: 400px;
}

#node-map {
    height: 300px;
}

/* Map label visibility */
.map-label {
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

.map-marker:hover .map-label {
    opacity: 1;
}

.show-labels .map-label {
    opacity: 1;
}

/* Bring hovered marker to front */
.leaflet-marker-icon:hover {
    z-index: 10000 !important;
}

/* ==========================================================================
   Node Header Hero Map Background
   ========================================================================== */

#header-map {
    height: 100%;
    width: 100%;
    z-index: 0;
}

/* Ensure Leaflet elements stay within the map layer */
#header-map .leaflet-pane,
#header-map .leaflet-control {
    z-index: auto !important;
}
