/*
 * Dark Theme Overlay for Cloud Asset Pro
 * Add this CSS after the main stylesheet to enable dark mode.
 * Remove this file (and its <link>) to revert to the default light theme.
 */

/* ============================================
   CSS Custom Properties (Dark Palette)
   ============================================ */
:root {
    --dark-bg: #111318;
    --dark-surface: #1a1d24;
    --dark-surface-hover: #21252e;
    --dark-surface-raised: #252930;
    --dark-surface-featured: #1e2129;
    --dark-border: rgba(255, 255, 255, 0.07);
    --dark-border-subtle: rgba(255, 255, 255, 0.04);
    --dark-text: #e2e4ea;
    --dark-text-muted: #969bab;
    --dark-text-faint: #5e6375;
    --accent: #c0392b;
    --accent-light: #e74c3c;
    --accent-glow: rgba(192, 57, 43, 0.12);
    --brand-blue: #009edb;
    --brand-blue-soft: #0086bd;
    --brand-blue-glow: rgba(0, 158, 219, 0.12);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-btn: 6px;
    --radius-input: 6px;
    --radius-pill: 20px;
    --shadow-card: 0 1px 8px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--dark-border);
    --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
    --transition: 0.2s ease;
}

/* ============================================
   Base / Body
   ============================================ */
body {
    background-color: var(--dark-bg) !important;
    color: var(--dark-text) !important;
}

.bg-brand-light,
[class*="bg-brand-light"],
.bg-\[\#F8F8F8\] {
    background-color: var(--dark-bg) !important;
}

.bg-white,
[class*="bg-white"] {
    background-color: var(--dark-surface) !important;
}

/* ============================================
   Logo – make white for dark backgrounds
   ============================================ */
a[title="Cloud Asset Pro"] img,
footer a img,
a.shrink-0 img {
    filter: brightness(0) invert(1) !important;
    opacity: 0.92;
}

/* ============================================
   Typography – eliminate ALL brand-blue text
   ============================================ */
.text-gray-900,
[class*="text-gray-900"] {
    color: var(--dark-text) !important;
}

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

.text-gray-700 {
    color: #c0c4d0 !important;
}

.text-gray-600 {
    color: var(--dark-text-muted) !important;
}

.text-gray-500 {
    color: var(--dark-text-muted) !important;
}

.text-gray-400 {
    color: var(--dark-text-faint) !important;
}

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

/* ALL brand-blue text becomes white/light — headings, counts, labels */
.text-brand-blue {
    color: #fff !important;
}

/* Headings */
h1, h2, h3 {
    color: #f0f1f4 !important;
}

/* Story title links – slightly softer white */
a .text-link,
.text-xl.font-bold,
h3.text-xl.font-bold {
    color: #eceef2 !important;
}

/* Body text */
p, li, span, div, td, th, label, small {
    color: inherit;
}

/* Content area links */
.content p a,
.content ul li a {
    color: #8cc8e0 !important;
}

.content p a:hover,
.content ul li a:hover {
    color: #b0ddef !important;
}

/* ============================================
   Header / Navigation
   ============================================ */
header,
.relative.bg-white.shadow-lg,
div.relative.bg-white.shadow-lg {
    background-color: var(--dark-surface) !important;
    border-bottom: 1px solid var(--dark-border) !important;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.35) !important;
}

/* Nav links */
nav a {
    border-radius: var(--radius-btn) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: var(--dark-text) !important;
    background-color: transparent !important;
    transition: all var(--transition) !important;
}

nav a:hover {
    border-color: rgba(255, 255, 255, 0.25) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}

/* ============================================
   Header search – match button style + spacing
   ============================================ */
.flex.justify-between {
    gap: 6px;
}

.form-search,
input.form-input.form-search {
    border-radius: var(--radius-btn) !important;
    background-color: var(--dark-surface-raised) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--dark-text) !important;
    height: 40px !important;
}

.form-search:focus,
input.form-input.form-search:focus {
    border-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) !important;
}

/* ============================================
   Buttons – replace blue with a refined dark style
   ============================================ */
.btn {
    border-radius: var(--radius-btn) !important;
    transition: all var(--transition) !important;
    font-weight: 600 !important;
}

/* Primary button – white on dark surface instead of blue */
.btn-brand-blue,
.btn.btn-brand-blue {
    background-color: #fff !important;
    border-color: #fff !important;
    color: #111318 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
}

.btn-brand-blue:hover,
.btn.btn-brand-blue:hover {
    background-color: #e2e4ea !important;
    border-color: #e2e4ea !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Outline button */
.btn-brand-outline,
.btn.btn-brand-outline {
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--dark-text) !important;
    background-color: transparent !important;
}

.btn-brand-outline:hover,
.btn.btn-brand-outline:hover {
    border-color: rgba(255, 255, 255, 0.3) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}

.btn-xs {
    border-radius: var(--radius-btn) !important;
}

/* ============================================
   bg-brand-blue elements (video play bar, etc.)
   Replace blue backgrounds with dark surface
   ============================================ */
.bg-brand-blue {
    background-color: #2a2e38 !important;
    color: #fff !important;
}

a.bg-brand-blue:hover {
    background-color: #343843 !important;
}

/* But keep .btn-brand-blue as white (higher specificity above handles it) */

/* ============================================
   Featured / Top Story Section (bg-brand-dark)
   ============================================ */
.bg-brand-dark,
section.bg-brand-dark {
    background-color: var(--dark-surface-featured) !important;
}

/* Story page main content area bg-white within bg-brand-dark */
section.bg-brand-dark .bg-white,
.bg-brand-dark .w-full.bg-white,
.bg-brand-dark .lg\:max-w-sm.bg-white {
    background-color: var(--dark-surface) !important;
    border-radius: var(--radius-lg) !important;
    overflow: hidden !important;
}

/* Border between main content and sidebar */
.lg\:border-r-4.border-brand-dark {
    border-color: var(--dark-border) !important;
}

/* ============================================
   Cards
   ============================================ */
.card,
.card-story,
[class*="shadow-lg"][class*="rounded-lg"],
.shadow-card {
    background-color: var(--dark-surface) !important;
    border: 1px solid var(--dark-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-card) !important;
    transition: all var(--transition) !important;
    overflow: hidden;
}

.card:hover,
.card-story:hover {
    box-shadow: var(--shadow-hover) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.group {
    transition: transform var(--transition), box-shadow var(--transition) !important;
}

.group:hover {
    transform: translateY(-2px);
}

.card img,
.card-story img {
    border-radius: 0 !important;
}

/* Only round overflow-hidden on image wrappers, not layout containers */
.group .overflow-hidden,
.card .overflow-hidden,
a .overflow-hidden {
    border-radius: var(--radius-md) !important;
}

/* ============================================
   Story Detail Page — Sidebar asset sections
   ============================================ */

/* bg-brand-ligther bars (User Generated Clips, Download all Photos,
   Download Storyline, Documents) */
.bg-brand-ligther,
[class*="bg-brand-ligther"] {
    background-color: var(--dark-surface-raised) !important;
    color: var(--dark-text) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

/* bg-brand-light bars (audio player container, audio download bar) */
.bg-brand-light {
    background-color: transparent !important;
    border-radius: var(--radius-md) !important;
    border: none !important;
    box-shadow: none !important;
}

/* Video thumbnail in sidebar */
.aspect-w-9 {
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

/* Video info bar below thumbnail (the blue play bar) */
a.bg-brand-blue.font-bold,
a[class*="bg-brand-blue"][class*="font-bold"][class*="text-white"][class*="text-sm"] {
    background-color: #2a2e38 !important;
    border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
}

/* Photo grid – round the individual photo containers */
.grid.grid-cols-2.gap-3 .relative {
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

/* Photo grid images */
.grid.grid-cols-2.gap-3 img {
    border-radius: var(--radius-md) !important;
}

/* Photo view/download buttons row – smaller, spaced */
.grid.grid-cols-2.gap-3 .flex.items-center.gap-1.justify-between {
    margin-top: 4px !important;
    gap: 4px !important;
}

.grid.grid-cols-2.gap-3 .flex.items-center.gap-1.justify-between .btn {
    padding: 4px 0 !important;
    height: 28px !important;
    font-size: 0.7rem !important;
    border-radius: var(--radius-sm) !important;
}

/* Sidebar panels borders */
.space-y-3 > div,
.space-y-4 > div,
.space-y-6 > div {
    border-color: var(--dark-border) !important;
}

/* Section count numbers (Videos 1, Photos 4, etc.) — already white via .text-brand-blue above */

/* ============================================
   Tab controls (Story / Shotlist / More Info)
   ============================================ */
.tab-wrapper .tab-control {
    border-radius: var(--radius-btn) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--dark-text-muted) !important;
    transition: all var(--transition) !important;
}

.tab-wrapper .tab-control:hover {
    background-color: var(--dark-surface-hover) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    color: var(--dark-text) !important;
}

.tab-wrapper .tab-control.active {
    background-color: #fff !important;
    border-color: #fff !important;
    color: #111318 !important;
}

/* ============================================
   Language badges (ENG, ESP, FRA, etc.)
   The blue ones become white, red ones stay
   ============================================ */
span[class*="bg-brand-blue"][class*="text-white"][class*="uppercase"],
span.bg-brand-blue.text-white {
    background-color: #fff !important;
    color: #111318 !important;
    border-radius: var(--radius-sm) !important;
}

/* Red language badges */
span[class*="bg-brand-red"][class*="text-white"][class*="uppercase"],
span.bg-brand-red {
    border-radius: var(--radius-sm) !important;
}

/* Similar stories language buttons */
.btn.btn-brand-blue.btn-xs.text-xs {
    background-color: #fff !important;
    color: #111318 !important;
    border-color: #fff !important;
}

/* ============================================
   Audio Player – dark styled
   ============================================ */
audio {
    width: 100% !important;
    border-radius: var(--radius-md) !important;
    background-color: var(--dark-surface-raised) !important;
}

/* Webkit audio player dark skin */
audio::-webkit-media-controls-panel {
    background-color: var(--dark-surface-raised) !important;
    border-radius: var(--radius-md) !important;
}

audio::-webkit-media-controls-current-time-display,
audio::-webkit-media-controls-time-remaining-display {
    color: var(--dark-text) !important;
}

audio::-webkit-media-controls-play-button,
audio::-webkit-media-controls-mute-button {
    filter: invert(0.85) !important;
}

audio::-webkit-media-controls-timeline {
    filter: invert(0.15) hue-rotate(180deg) !important;
}

/* Audio container section */
#playerAudio {
    border-radius: var(--radius-md) !important;
}

/* Audio section download bar – needs visible bg unlike the player wrapper */
.bg-brand-light.flex.items-center.justify-between {
    background-color: var(--dark-surface-raised) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

/* ============================================
   Footer
   ============================================ */
footer,
footer.relative.bg-white {
    background-color: var(--dark-surface) !important;
    border-top: 1px solid var(--dark-border) !important;
    color: var(--dark-text) !important;
}

footer .text-xl {
    color: #fff !important;
}

footer .text-link,
footer a {
    color: var(--dark-text-muted) !important;
    transition: color var(--transition) !important;
}

footer a:hover,
footer .text-link:hover {
    color: #fff !important;
}

footer hr {
    border-color: var(--dark-border) !important;
}

footer .text-xs {
    color: var(--dark-text-faint) !important;
}

/* ============================================
   Forms – dark inputs
   ============================================ */
.form-input,
.form-textarea,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    background-color: var(--dark-surface-raised) !important;
    color: var(--dark-text) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--radius-input) !important;
    --tw-ring-color: rgba(255, 255, 255, 0.15) !important;
    transition: border-color var(--transition), box-shadow var(--transition) !important;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) !important;
    outline: none !important;
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--dark-text-faint) !important;
}

.form-checkbox,
.form-radio {
    background-color: var(--dark-surface-raised) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.form-newsletter {
    border-radius: var(--radius-input) !important;
}

/* ============================================
   Search overlay
   ============================================ */
#search-overlay {
    background-color: rgba(17, 19, 24, 0.97) !important;
    backdrop-filter: blur(8px) !important;
}

.search-results-dropdown {
    background: var(--dark-surface) !important;
    border-color: var(--dark-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-card) !important;
}

.search-result-item {
    border-bottom-color: var(--dark-border) !important;
}

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

.result-date,
.result-categories {
    color: var(--dark-text-muted) !important;
}

/* ============================================
   Category badges / pills
   ============================================ */
.text-brand-red,
[class*="text-brand-red"] {
    color: var(--accent-light) !important;
}

/* ============================================
   Dividers & Borders
   ============================================ */
hr {
    border-color: var(--dark-border) !important;
}

.border-brand-light,
[class*="border-brand-light"] {
    border-color: var(--dark-border) !important;
}

.border-b {
    border-color: var(--dark-border) !important;
}

.divide-black\/30 > :not([hidden]) ~ :not([hidden]),
.divide-y > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--dark-border) !important;
}

/* ============================================
   Tables
   ============================================ */
.table td {
    border-bottom-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

.table th {
    color: var(--dark-text-muted) !important;
}

/* ============================================
   Dropdown menus
   ============================================ */
.dropdown-menu ul {
    background-color: var(--dark-surface-raised) !important;
    border-color: var(--dark-border) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.dropdown-menu a {
    color: var(--dark-text) !important;
}

.dropdown-menu a:hover {
    background-color: var(--dark-surface-hover) !important;
    color: #fff !important;
}

/* ============================================
   Mobile menu
   ============================================ */
.block.xl\:hidden.bg-\[\#F8F8F8\],
[x-show="mobileMenu"] {
    background-color: var(--dark-surface) !important;
    border-top-color: var(--dark-border) !important;
}

.block.xl\:hidden a {
    color: var(--dark-text) !important;
}

/* ============================================
   Modals (brand guidelines popups)
   ============================================ */
.fixed.z-50 .bg-white,
.fixed.z-50 .shadow-xl.bg-white {
    background-color: var(--dark-surface) !important;
    border: 1px solid var(--dark-border) !important;
    border-radius: var(--radius-lg) !important;
}

/* ============================================
   Tooltips
   ============================================ */
.tooltip-content {
    background-color: var(--dark-surface-raised) !important;
    border: 1px solid var(--dark-border) !important;
    border-radius: var(--radius-sm) !important;
}

/* ============================================
   Icon badges on thumbnails
   ============================================ */
[class*="bg-brand-grey"] {
    background-color: rgba(30, 33, 41, 0.8) !important;
    backdrop-filter: blur(4px) !important;
    border-radius: var(--radius-sm) !important;
}

[class*="bg-black"][class*="bg-opacity"],
.bg-black.bg-opacity-50,
.bg-black\/50 {
    background-color: rgba(17, 19, 24, 0.75) !important;
    border-radius: var(--radius-sm) !important;
    backdrop-filter: blur(4px) !important;
}

/* bg-black for image placeholder backgrounds – only inside cards/stories */
.card .relative.bg-black,
.card-story .relative.bg-black,
a.relative.bg-black {
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

/* ============================================
   Shadows
   ============================================ */
.shadow-lg {
    box-shadow: var(--shadow-card) !important;
}

.shadow-md {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25) !important;
}

/* ============================================
   Scrollbar (Webkit)
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #33373f;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #474c57;
}

/* ============================================
   Cookie consent
   ============================================ */
.cc-window {
    background-color: var(--dark-surface-raised) !important;
    border: 1px solid var(--dark-border) !important;
    border-radius: var(--radius-md) !important;
    color: var(--dark-text) !important;
}

.cc-btn.cc-dismiss {
    border-radius: var(--radius-btn) !important;
}

/* ============================================
   Video.js player – dark frame & rounded
   ============================================ */
.video-js,
#im8player {
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

.vjs-poster {
    border-radius: var(--radius-md) !important;
}

/* ============================================
   Similar Stories section
   ============================================ */
section.bg-white {
    background-color: var(--dark-bg) !important;
}

/* Aspect ratio image containers in similar stories */
.aspect-w-5 {
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
}

/* ============================================
   Miscellaneous polish
   ============================================ */
a, button, input, select, textarea {
    transition: color var(--transition), background-color var(--transition),
                border-color var(--transition), box-shadow var(--transition) !important;
}

/* Subtle image rounding */
img {
    border-radius: var(--radius-sm);
}

/* Images inside cards follow card shape */
.card img,
.card-story img {
    border-radius: 0 !important;
}

/* Remove hard white backgrounds */
[style*="background: white"],
[style*="background-color: white"],
[style*="background:#fff"],
[style*="background-color:#fff"] {
    background-color: var(--dark-surface) !important;
}

/* Selection highlight */
::selection {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Fancybox */
.fancybox__backdrop {
    background-color: rgba(17, 19, 24, 0.95) !important;
}

/* Ring overrides */
[class*="ring-brand-blue"] {
    --tw-ring-color: rgba(255, 255, 255, 0.12) !important;
}

/* Separator dot between date and categories */
.bg-brand-dark.h-2\.5 {
    background-color: var(--dark-text-muted) !important;
}

/* ============================================
   Print – revert everything
   ============================================ */
@media print {
    body,
    .bg-brand-light,
    .bg-white,
    footer,
    header {
        background-color: #fff !important;
        color: #000 !important;
    }

    a[title="Cloud Asset Pro"] img,
    footer a img,
    a.shrink-0 img {
        filter: none !important;
        opacity: 1 !important;
    }

    .btn-brand-blue,
    .btn.btn-brand-blue {
        background-color: #009edb !important;
        color: #fff !important;
    }
}
