﻿/* ===== MODERN CLEAN THEME ===== */
:root {
    --bg-primary: #18181b;
    --bg-secondary: #1f2024;
    --bg-tertiary: #27282d;
    --text-primary: #efeff1;
    --text-secondary: #c8c8d0;
    --text-muted: #a0a0a8;
    --border-color: #3a3b40;
    --accent-purple: #9147ff;
    --accent-purple-hover: #772ce8;
    --accent-green: #00f593;
    --accent-red: #eb0400;
    --accent-blue: #1f69ff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    font-size: 14px;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #fff !important;
    font-weight: 600;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

h5 {
    font-size: 1rem;
}

h6 {
    font-size: 0.875rem;
}

/* ===== TEXT ELEMENTS ===== */
p,
div,
span,
td,
th,
label,
li,
dd,
dt {
    color: var(--text-primary) !important;
}

strong,
b {
    color: #fff !important;
    font-weight: 600;
}

small,
.small {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-purple-hover);
    text-decoration: none;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1200px;
}

.site-header {
    background: var(--bg-secondary);
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.site-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff !important;
}

.site-header h1 a {
    color: #fff !important;
}

.site-header h1 a:hover {
    color: var(--accent-purple) !important;
}

main.container {
    margin-top: 1.5rem;
}

.site-footer {
    background: var(--bg-secondary);
    padding: 1rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
}

/* ===== NAVIGATION ===== */
.mainnav .topnav {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.mainnav .topnav>li {
    position: relative;
}

.mainnav .topnav>li>a {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    color: var(--text-primary) !important;
    font-weight: 500;
    font-size: 0.875rem;
}

.mainnav .topnav>li>a:hover,
.mainnav .topnav>li:hover>a {
    background: var(--bg-tertiary);
    color: #fff !important;
}

/* Submenu wrapper with invisible bridge to prevent gap issues */
.mainnav .has-submenu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
    display: none;
}

.mainnav .has-submenu:hover::after {
    display: block;
}

.mainnav .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-width: 180px;
    padding: 0.375rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-top: 0;
}

.mainnav .submenu li {
    list-style: none;
}

.mainnav .submenu a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    white-space: nowrap;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.mainnav .submenu a:hover {
    background: rgba(145, 71, 255, 0.2);
    color: #fff !important;
}

.mainnav .has-submenu:hover>.submenu,
.mainnav .submenu:hover {
    display: block;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary) !important;
}

.card p,
.card div,
.card span,
.card td,
.card th,
.card label,
.card strong {
    color: var(--text-primary) !important;
}

.card h2,
.card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #fff !important;
    font-weight: 600;
    font-size: 1.125rem;
}

.card-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    margin: -1rem -1rem 1rem -1rem;
    border-radius: 6px 6px 0 0;
}

.card-header h5,
.card-header h6 {
    margin: 0;
    color: #fff !important;
    font-weight: 600;
    font-size: 1rem;
}

.card-body {
    color: var(--text-primary) !important;
}

.card-title {
    color: var(--accent-purple) !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    margin-bottom: 1rem !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    font-size: 1.1rem;
    opacity: 0.9;
}

.card-body p,
.card-body div,
.card-body span,
.card-body strong {
    color: var(--text-primary) !important;
}

/* ===== FORMS ===== */
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: #fff !important;
    font-size: 0.875rem;
}

.form-control,
.form-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease;
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-primary);
    border-color: var(--accent-purple);
    box-shadow: none;
    color: var(--text-primary);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    cursor: pointer;
    accent-color: var(--accent-purple);
}

.form-check {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.form-check-input {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    margin-left: 0;
    cursor: pointer;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.form-check-input:checked {
    background-color: var(--accent-purple);
    border-color: var(--accent-purple);
}

.form-check-input:focus {
    border-color: var(--accent-purple);
    box-shadow: none;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
    color: #fff !important;
    margin-bottom: 0;
    line-height: 1.5;
    font-size: 0.875rem;
}

/* Legacy support for old markup */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="color"],
textarea,
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    transition: border-color 0.15s ease;
    font-size: 0.875rem;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="color"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: var(--bg-primary);
}

input[type="color"],
.form-control-color {
    height: 3rem;
    padding: 0.375rem;
    cursor: pointer;
}

input[type="range"],
.form-range {
    width: 100%;
    height: 2rem;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track,
.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb,
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-purple);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover,
.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--accent-purple-hover);
}

input[type="range"]::-moz-range-track,
.form-range::-moz-range-track {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb,
.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-purple);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

input[type="range"]::-moz-range-thumb:hover,
.form-range::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: var(--accent-purple-hover);
}

/* ===== BUTTONS ===== */
.btn {
    font-weight: 500;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
    display: inline-block;
    text-align: center;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--accent-purple);
    border: none;
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-purple-hover);
    color: #fff;
}

.btn-success {
    background: var(--accent-green);
    border: none;
    color: #000;
}

.btn-success:hover {
    background: #00d17a;
    color: #000;
}

.btn-danger {
    background: var(--accent-red);
    border: none;
    color: #fff;
}

.btn-danger:hover {
    background: #c00300;
    color: #fff;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #35363c;
    color: var(--text-primary);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Legacy button support */
button,
input[type="submit"] {
    background: var(--accent-purple);
    border: none;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

button:hover:not(:disabled),
input[type="submit"]:hover:not(:disabled) {
    background: var(--accent-purple-hover);
}

button:disabled,
input[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button {
    display: inline-block;
    background: var(--accent-purple);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.button:hover {
    background: var(--accent-purple-hover);
    color: #fff;
}

/* ===== ALERTS & NOTIFICATIONS ===== */
.alert-preview {
    border: 1px solid;
    padding: 1rem;
    border-radius: 0.75rem;
    margin: 1rem 0;
    font-weight: 500;
}

.alert-success {
    background: rgba(0, 245, 147, 0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.alert-danger {
    background: rgba(235, 4, 0, 0.1);
    border-color: var(--accent-red);
    color: #ff8080;
}

.alert-info {
    background: rgba(31, 105, 255, 0.1);
    border-color: var(--accent-blue);
    color: #6b9eff;
}

/* ===== TABLES ===== */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
    font-size: 0.875rem;
    /* Ensure dark theme regardless of Bootstrap defaults */
    background-color: var(--bg-secondary);
    /* Bootstrap 5 table CSS variable overrides */
    --bs-table-bg: var(--bg-secondary);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: var(--bg-tertiary);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
}

.table thead th {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
}

.table tbody tr {
    border-color: var(--border-color);
    background-color: var(--bg-secondary);
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

.table tbody td {
    padding: 0.625rem 0.75rem;
    vertical-align: middle;
    color: #fff !important;
    background-color: var(--bg-secondary);
    font-size: 0.875rem;
}

.table tbody td.fw-semibold {
    color: #fff !important;
}

/* ===== FIELDSETS ===== */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-tertiary);
}

fieldset legend {
    background: var(--accent-purple);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
    float: none;
    width: auto;
}

/* ===== STATUS BADGES ===== */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
}

.bg-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.bg-primary {
    background: var(--accent-purple);
    color: #fff;
}

.bg-success {
    background: var(--accent-green);
    color: #000;
}

.bg-danger {
    background: var(--accent-red);
    color: #fff;
}

.status-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    background: var(--bg-primary);
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.status-card:hover {
    border-color: var(--accent-purple);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(145, 71, 255, 0.15);
}

.status-card .fw-semibold {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.status-active {
    color: var(--accent-green) !important;
    font-size: 0.875rem;
}

.status-inactive {
    color: var(--text-muted) !important;
    font-size: 0.875rem;
}

/* Ensure status/text colors are not overridden by .card span or table cell defaults */
.card .status-active,
.table .status-active {
    color: var(--accent-green) !important;
}

.card .status-inactive,
.table .status-inactive {
    color: var(--accent-red) !important;
}

/* Respect Bootstrap text-* utilities inside cards/tables despite generic span color rules */
.card .text-success,
.table .text-success {
    color: var(--accent-green) !important;
}

.card .text-danger,
.table .text-danger {
    color: var(--accent-red) !important;
}

/* Stats styling */
.stat-item {
    padding: 0.5rem 0;
}

.text-warning {
    color: #ffa500;
}

.alert-box {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(17, 24, 39, 0.85);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(147, 197, 253, 0.4);
    color: #f9fafb;
    text-align: center;
    font-size: 2rem;
    min-width: 400px;
    animation-duration: 1s;
}

.alert-box.pop-in {
    animation-name: alertPop;
}

.alert-box.slide-up {
    animation-name: alertSlide;
}

.alert-box.shake {
    animation-name: alertShake;
}

.alert-box.pulse {
    animation-name: alertPulse;
}

@keyframes alertPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    60% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes alertSlide {
    0% {
        transform: translate(-50%, -20%);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

@keyframes alertShake {

    0%,
    100% {
        transform: translate(-50%, -50%);
    }

    20% {
        transform: translate(calc(-50% + 10px), -50%);
    }

    40% {
        transform: translate(calc(-50% - 10px), -50%);
    }

    60% {
        transform: translate(calc(-50% + 8px), -50%);
    }

    80% {
        transform: translate(calc(-50% - 8px), -50%);
    }
}

@keyframes alertPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ===== UTILITY CLASSES ===== */
.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.ms-1 {
    margin-left: 0.25rem;
}

/* ===== TEXT UTILITIES ===== */
.text-muted {
    color: var(--text-secondary) !important;
    opacity: 1;
}

.form-text {
    color: var(--text-secondary) !important;
    font-size: 0.8125rem;
}

.text-white {
    color: #fff !important;
}

small,
.small {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.text-end {
    text-align: end;
}

.fw-semibold {
    font-weight: 600;
}

.fw-bold {
    font-weight: 700;
}

.d-flex {
    display: flex;
}

.d-inline {
    display: inline;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.border {
    border: 1px solid var(--border-color);
}

.rounded {
    border-radius: 4px;
}

.rounded-circle {
    border-radius: 50%;
}

.p-2 {
    padding: 0.5rem;
}

.m-0 {
    margin: 0;
}

/* ===== INPUT GROUP ===== */
.input-group {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
    margin-bottom: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    white-space: nowrap;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 0.5rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    height: auto;
}

/* ===== BOOTSTRAP GRID SUPPORT ===== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.col,
.col-auto,
[class*="col-"] {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.col-auto {
    flex: 0 0 auto;
    width: auto;
}

.col {
    flex: 1 0 0%;
}

.col-md-4 {
    flex: 0 0 auto;
    width: 33.333333%;
}

.col-md-6 {
    flex: 0 0 auto;
    width: 50%;
}

.col-md-8 {
    flex: 0 0 auto;
    width: 66.666667%;
}

.col-lg-4 {
    flex: 0 0 auto;
    width: 33.333333%;
}

.g-2>* {
    padding: 0.5rem;
}

.g-3>* {
    padding: 1rem;
}

@media (max-width: 768px) {

    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-lg-4 {
        width: 100%;
    }
}

/* ===== TABLE RESPONSIVE ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Strong override for Bootstrap cell background in all sections of a table */
.table> :not(caption)>*>* {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Fallback styling for any plain <table> without .table class */
table {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

table thead th {
    background-color: var(--bg-tertiary);
}

table td,
table th {
    border-color: var(--border-color);
}

/* ===== PAGINATION (dark theme) ===== */
.pagination {
    display: flex;
    gap: 0.25rem;
}

.page-item .page-link {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.page-item .page-link:hover {
    background-color: #35363c;
    color: #fff;
    border-color: var(--border-color);
}

.page-item.active .page-link {
    background-color: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}

.page-item.disabled .page-link {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* ===== SECTION TOGGLE (accordion headers) ===== */
.section-toggle {
    background: transparent;
    color: #fff;
    border: 0;
    width: 100%;
    text-align: left;
    padding: 0;
    font: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-toggle:focus {
    outline: none;
}

.section-toggle::after {
    content: '\25BC';
    font-size: 0.9rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
}

.section-toggle[aria-expanded="false"]::after {
    transform: rotate(-90deg);
}

/* ===== SPECIFIC COMPONENTS ===== */
.legacy-visual-wrapper {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Alert lists (Alerts menu) – unify button text color in list rows
   Applies to Follows/Subs/Raids/Cheers/Donations pages using .alert-rule-row
   (Rewards are rendered in tables and are not affected) */
.alert-rule-row .btn,
.alert-rule-row .btn:hover,
.alert-rule-row .btn:focus {
    color: #fff !important;
}

.legacy-visual-wrapper .legacy-input,
.legacy-visual-wrapper select,
.legacy-input {
    flex: 1 1 220px;
}

.legacy-input:disabled {
    opacity: 0.5;
}

.frame-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.frame-controls label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.frame-controls .range-field {
    display: flex;
    flex-direction: column;
}

.frame-controls .range-field input[type="range"] {
    margin-bottom: 0;
    accent-color: var(--accent-purple);
}

.frame-controls .range-value {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* ===== COMMAND/TIMER CARDS ===== */
.command-card,
.timer-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    transition: all 0.15s ease;
}

.command-card:hover,
.timer-card:hover {
    border-color: var(--accent-purple);
    background: var(--bg-secondary);
}

.command-card strong,
.timer-card strong {
    color: var(--accent-purple);
    font-size: 1rem;
}

/* Code blocks */
code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    color: var(--accent-purple);
    font-size: 0.875em;
}

small {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .site-header h1 {
        font-size: 1.25rem;
    }

    .mainnav .topnav {
        flex-direction: column;
        gap: 0.25rem;
    }

    .frame-controls {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1rem;
    }
}

/* ===== COMPACT SCALE ADJUSTMENTS (reduce overall UI size) ===== */
/* This block intentionally comes at the end to override earlier rules. */

/* Typography & spacing */
body {
    font-size: 15px;
    /* slightly smaller base for tighter UI */
}

.container main,
main.container {
    margin-top: 1rem;
}

.site-header {
    padding: 0.75rem 0;
}

.site-footer {
    padding: 1rem 0;
    margin-top: 2rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* Cards */
.card {
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.card-header {
    padding: 0.75rem 1rem;
    margin: -1rem -1rem 1rem -1rem;
    border-radius: 0.75rem 0.75rem 0 0;
}

/* Forms */
.form-label {
    margin-bottom: 0.375rem;
}

.form-control,
.form-select,
input[type="text"],
input[type="url"],
input[type="number"],
input[type="color"],
textarea,
select {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.form-check {
    padding: 0.5rem 0.75rem 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
}

input[type="color"],
.form-control-color {
    height: 2.5rem;
}

input[type="range"],
.form-range {
    height: 1.25rem;
}

input[type="range"]::-webkit-slider-runnable-track,
.form-range::-webkit-slider-runnable-track {
    height: 0.375rem;
}

input[type="range"]::-webkit-slider-thumb,
.form-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    margin-top: -0.3125rem;
}

input[type="range"]::-moz-range-track,
.form-range::-moz-range-track {
    height: 0.375rem;
}

input[type="range"]::-moz-range-thumb,
.form-range::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
}

/* Input group */
.input-group-text {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.input-group .btn {
    padding: 0.5rem 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 0.9rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Tables */
.table thead th {
    padding: 0.625rem;
}

.table tbody td {
    padding: 0.625rem;
}

/* Fieldsets */
fieldset {
    padding: 1rem;
    border-radius: 0.5rem;
}

fieldset legend {
    padding: 0.25rem 0.75rem;
    font-size: 0.9rem;
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
}

/* Status cards */
.status-card {
    padding: 0.75rem;
}

/* Alert box overlay */
.alert-box {
    padding: 1.5rem;
    font-size: 1.5rem;
    min-width: 360px;
}

/* Frame controls */
.frame-controls {
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.frame-controls label {
    margin-bottom: 0.375rem;
}

.frame-controls .range-value {
    font-size: 0.8rem;
}

/* Overlay preview responsive container */
.overlay-preview-wrapper {
    background: #000;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    height: 360px;
}

.overlay-preview-wrapper .overlay-preview-iframe,
.overlay-preview-iframe {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    border: 0;
}

@media (min-width: 992px) {
    .overlay-preview-wrapper {
        height: 480px;
    }
}

@media (min-width: 1200px) {
    .overlay-preview-wrapper {
        height: 560px;
    }
}

/* Alert Edit Layout - Two column design */
.alert-edit-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.alert-edit-settings {
    position: sticky;
    top: 1rem;
    max-height: none;
    overflow: visible;
}

.alert-edit-settings .card {
    padding: 1.5rem;
}

.alert-edit-preview {
    min-height: 600px;
}

/* Alert Preview Container */
.alert-preview-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.alert-preview-header {
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.alert-preview-controls {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.alert-preview-frame {
    background: #000;
    position: relative;
    width: 100%;
    height: 500px;
    min-height: 500px;
}

.alert-preview-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.alert-preview-footer {
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* Right column grid of settings under preview */
.alert-right-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 1200px) {
    .alert-right-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Make forms in edit settings and right grid more compact */
.alert-edit-settings .card,
.alert-right-grid .card {
    padding: 0.75rem;
}

.alert-edit-settings .form-label,
.alert-right-grid .form-label {
    margin-bottom: 0.25rem;
}

.alert-edit-settings .mb-3,
.alert-right-grid .mb-3 {
    margin-bottom: 0.5rem !important;
}

.alert-edit-settings .row,
.alert-right-grid .row {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 0.5rem;
}

.alert-edit-settings .form-control:not(textarea),
.alert-right-grid .form-control:not(textarea),
.alert-edit-settings .form-select,
.alert-right-grid .form-select {
    padding: 0.25rem 0.5rem;
    height: 34px;
    font-size: 0.9rem;
}

.alert-edit-settings input[type="color"],
.alert-right-grid input[type="color"] {
    height: 36px;
}

/* Utility: span across grid */
.alert-grid-span-2 {
    grid-column: 1 / -1;
}

/* Responsive - Mobile */
@media (max-width: 991px) {
    .alert-edit-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .alert-edit-settings {
        position: static;
        max-height: none;
        order: 2;
    }

    .alert-edit-preview {
        order: 1;
        min-height: 400px;
    }

    .alert-preview-frame {
        height: 350px;
        min-height: 350px;
    }

    .alert-preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .alert-preview-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (min-width: 1400px) {
    .alert-edit-layout {
        grid-template-columns: 420px 1fr;
    }

    .alert-preview-frame {
        height: 600px;
    }
}

/* Media select wrapper */
.media-select-wrapper {
    position: relative;
}

/* Form switch larger */
.form-check.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
}

/* ===== TABS STYLING ===== */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0;
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1.25rem;
    margin-bottom: -2px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-color: transparent;
    background: rgba(255, 255, 255, 0.05);
}

.nav-tabs .nav-link.active {
    color: var(--accent-purple);
    background: transparent;
    border-bottom-color: var(--accent-purple);
}

.tab-content {
    background: var(--bg-secondary);
}

.tab-pane {
    background: var(--bg-secondary);
}