:root {
    /* Dark theme variables (default) */
    --bg-primary: #1a1a1a;      /* Main background */
    --bg-secondary: #2a2a2a;    /* Secondary background */
    --text-primary: #ffffff;    /* Primary text */
    --text-secondary: #a0a0a0;  /* Secondary text */
    --border-color: #404040;    /* Borders */
    --link-color: #66b3ff;      /* Links */
    --link-hover-color: #99ccff; /* Link hover */
    --navbar-bg: #2a2a2a;       /* Navbar background */
    --card-bg: #282828;         /* Card background */
    --input-bg: #282828;        /* Input background */
    --input-border: #404040;    /* Input borders */
    /* Tells the browser its own canvas, form controls and scrollbars should be dark,
       so the blank frame between page loads is not white. */
    color-scheme: dark;
}

[data-theme="light"] {
    /* Light theme variables */
    color-scheme: light;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --link-color: #0d6efd;
    --link-hover-color: #0a58ca;
    --navbar-bg: #ffffff;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #ced4da;
}

/* Theme switch animation */
.theme-switch-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 75vw;  /* 75% of viewport width */
    height: auto; /* Auto height to maintain aspect ratio */
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
    background-color: transparent;
}

.theme-switch-animation.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.theme-animation-gif,
.theme-animation-video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Maintain aspect ratio */
    filter: brightness(1.2);
    display: none; /* Hide both by default */
    transition: filter 0.3s ease;
}

/* Dark mode media adjustments */
[data-theme="dark"] .theme-animation-gif,
[data-theme="dark"] .theme-animation-video {
    filter: brightness(0.7) contrast(1.2) saturate(0.8);
}

/* Show the appropriate media type based on class */
.theme-switch-animation.use-gif .theme-animation-gif {
    display: block;
}

.theme-switch-animation.use-video .theme-animation-video {
    display: block;
}

/* Add a responsive breakpoint for smaller screens */
@media (max-width: 768px) {
    .theme-switch-animation {
        width: 90vw; /* Wider on mobile */
    }
}

/* Base styles */
/* The html background covers the whole viewport during load, before body has laid out. */
html {
    background-color: var(--bg-primary);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navbar styles */
.navbar {
    background-color: var(--navbar-bg) !important;
    border-color: var(--border-color) !important;
}

.navbar-light .navbar-brand,
.navbar-light .navbar-nav .nav-link {
    color: var(--text-primary) !important;
}

/* Card styles */
.card {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

.card-header,
.card-footer {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Table styles */
.table {
    color: var(--text-primary);
}

.table thead th {
    border-color: var(--border-color);
}

.table td, .table th {
    border-color: var(--border-color);
}

/* Form styles */
.form-control {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}

.form-control:focus {
    background-color: var(--input-bg);
    border-color: var(--link-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 179, 255, 0.25);
}

.form-control.loading {
    opacity: 0.7;
    cursor: wait;
}

/* Dropdown styles */
select.form-control {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
}

select.form-control option {
    background-color: var(--input-bg);
    color: var(--text-primary);
}

[data-theme="dark"] select.form-control {
    background-color: var(--input-bg);
    border-color: var(--input-border);
}

[data-theme="dark"] select.form-control option {
    background-color: #2d2d2d;  /* Slightly lighter than input background for contrast */
}

/* Link styles */
a {
    color: var(--link-color);
}

a:hover {
    color: var(--link-hover-color);
}

/* Border utilities */
.border {
    border-color: var(--border-color) !important;
}

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

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

/* Footer styles */
.footer {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Theme toggle button styles */
.theme-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    margin-left: 1rem;
    cursor: pointer;
    color: var(--text-primary);
}

.theme-toggle:hover {
    color: var(--link-color);
}

.theme-toggle i {
    font-size: 1.25rem;
} 