/* OpAgent Theme System */

/* CSS Custom Properties for Theme Variables */
:root {
    /* Light Theme Colors */
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-color: #4f46e5;
    --danger-color: #ff6b6b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    /* Background Colors */
    --body-bg: #f8f9fa;
    --card-bg: #ffffff;
    --sidebar-bg: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    --content-bg: #ffffff;

    /* Text Colors */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #6c757d;
    --text-light: rgba(255, 255, 255, 0.9);

    /* Border Colors */
    --border-color: #e0e0e0;
    --border-light: #e2e8f0;

    /* Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --shadow-strong: rgba(0, 0, 0, 0.25);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.12);

    /* Table Colors */
    --table-row-alt: rgba(0, 0, 0, 0.025);

    /* Interactive States */
    --hover-bg: rgba(102, 126, 234, 0.1);
    --active-bg: var(--primary-gradient);
    --focus-ring: rgba(102, 126, 234, 0.3);
}

/* Apply theme to body and basic elements */
body {
    background-color: var(--body-bg) !important;
    color: var(--text-primary) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.content-wrapper,
.main-content,
.card,
.card-body {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

.sidebar {
    background: var(--sidebar-bg) !important;
    color: var(--text-primary) !important;
}

/* Dark Theme Colors */
[data-theme="dark"] {
    /* Primary colors remain the same for brand consistency */
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-color: #6366f1;
    --danger-color: #f87171;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --info-color: #60a5fa;

    /* Dark Background Colors */
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --sidebar-bg: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    --content-bg: #0f172a;

    /* Dark Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-light: rgba(255, 255, 255, 0.9);

    /* Dark Border Colors */
    --border-color: #334155;
    --border-light: #475569;

    /* Dark Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.4);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --shadow-strong: rgba(0, 0, 0, 0.7);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.4);

    /* Dark Table Colors */
    --table-row-alt: rgba(255, 255, 255, 0.05);

    /* Dark Interactive States */
    --hover-bg: rgba(102, 126, 234, 0.2);
    --active-bg: var(--primary-gradient);
    --focus-ring: rgba(102, 126, 234, 0.4);
}

/* Theme Toggle Button Styles */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow-medium);
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--shadow-strong);
}

/* Breadcrumb Hierarchy Styles */
.hierarchy-breadcrumbs {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.hierarchy-breadcrumbs .breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
}

.hierarchy-breadcrumbs .breadcrumb-item {
    color: var(--text-primary);
}

.hierarchy-breadcrumbs .breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.hierarchy-breadcrumbs .breadcrumb-item a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.hierarchy-breadcrumbs .breadcrumb-item.active {
    color: var(--text-secondary);
}

.hierarchy-breadcrumbs .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: var(--text-secondary);
    font-weight: bold;
    float: none;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* Ensure breadcrumb icons are visible */
.hierarchy-breadcrumbs .fas {
    color: var(--text-secondary);
}

/* Quick date filter buttons (used across report pages) */
.quickdate.active {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
}

/* Theme-aware section/info rows in tables */
.table-info,
.table-info > th,
.table-info > td {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Datatable-styled helpers for non-DataTables tables too */
.datatable-styled tfoot th,
.datatable-styled tfoot td {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Better highlight for section rows when using datatable-styled */
.datatable-styled tr.table-info td,
.datatable-styled tr.section-row td {
    background-color: var(--hover-bg) !important;
    color: var(--primary-color) !important;
}

/* Dark theme specific breadcrumb overrides */
[data-theme="dark"] .hierarchy-breadcrumbs {
    border-color: var(--border-color);
    background-color: var(--card-bg);
}

[data-theme="dark"] .hierarchy-breadcrumbs .breadcrumb-item {
    color: var(--text-primary);
}

[data-theme="dark"] .hierarchy-breadcrumbs .breadcrumb-item a {
    color: var(--primary-color);
}

[data-theme="dark"] .hierarchy-breadcrumbs .breadcrumb-item.active {
    color: var(--text-secondary);
}

[data-theme="dark"] .hierarchy-breadcrumbs .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-secondary);
}

[data-theme="dark"] .hierarchy-breadcrumbs .fas {
    color: var(--text-secondary);
}

/* Sidebar Theme Toggle Extended Styles */
.theme-toggle-extended {
    background: var(--primary-gradient);
    color: var(--text-light);
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    width: 100%;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.theme-toggle-extended:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--focus-ring);
}

.theme-toggle-extended i {
    margin-right: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.sidebar.collapsed .theme-toggle {
    padding: 1rem 0.75rem;
    justify-content: center;
}

.sidebar.collapsed .theme-toggle i {
    margin-right: 0;
}

.sidebar.collapsed .theme-toggle span {
    opacity: 0;
    transform: translateX(-20px);
    position: absolute;
    width: 0;
    overflow: hidden;
}

/* Login Theme Toggle */
.login-theme-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--card-bg);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.login-theme-toggle:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.05);
}

/* Theme transition animations */
* {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Apply theme to body and html */
html, body {
    background-color: var(--body-bg) !important;
    color: var(--text-primary) !important;
}

/* Main container theming */
.container, .container-fluid {
    background-color: var(--body-bg);
    color: var(--text-primary);
}

/* Override Bootstrap dark mode conflicts */
[data-theme="dark"] .bg-light {
    background-color: var(--body-bg) !important;
}

[data-theme="dark"] .card {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .border-0 {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] p, [data-theme="dark"] div, [data-theme="dark"] span {
    color: var(--text-primary);
}

[data-theme="dark"] .shadow-lg {
    box-shadow: 0 1rem 3rem var(--shadow-strong) !important;
}

/* Form controls dark theme */
[data-theme="dark"] .form-control {
    background-color: #374151 !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .form-control:focus {
    background-color: #4b5563 !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem var(--focus-ring) !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted) !important;
}

/* Button dark theme */
[data-theme="dark"] .btn-primary {
    background: var(--primary-gradient) !important;
    border-color: var(--primary-color) !important;
}

[data-theme="dark"] .btn-link {
    color: var(--primary-color) !important;
}

/* Dropdown dark theme */
[data-theme="dark"] .dropdown-menu {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--hover-bg) !important;
    color: var(--primary-color) !important;
}

/* Alert dark theme */
[data-theme="dark"] .alert-danger {
    background-color: rgba(248, 113, 113, 0.1) !important;
    border-color: var(--danger-color) !important;
    color: var(--danger-color) !important;
}

/* Theme section styling */
.theme-section {
    padding: 0.75rem 0.25rem;
    border-top: 1px solid var(--border-light);
    margin-top: 0.5rem;
}

.sidebar.collapsed .theme-section {
    padding: 0.75rem 0.15rem;
}

/* Additional theme classes for JavaScript application */
.theme-dark-bg {
    background-color: var(--body-bg) !important;
}

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

/* Tab System Theme Styles */

/* Light Theme Tab Styles */
.flex-tabs {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-light);
}

.flex-tab.light-theme {
    background: #f7fafc;
    border-color: var(--border-light);
    color: var(--text-secondary);
}

.flex-tab.light-theme:hover {
    background: #edf2f7;
}

.flex-tab.light-theme.active {
    background: var(--card-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.flex-contents.light-theme {
    background: var(--card-bg);
}

.flex-content.light-theme {
    background: var(--card-bg);
}

/* Dark Theme Tab Styles */
.flex-tabs[data-theme="dark"] {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.flex-tab.dark-theme {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.flex-tab.dark-theme:hover {
    background: #1e293b;
}

.flex-tab.dark-theme.active {
    background: var(--card-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.flex-tab.dark-theme .flex-close {
    color: var(--text-muted);
}

.flex-tab.dark-theme .flex-close:hover {
    color: var(--danger-color);
    background: rgba(248, 113, 113, 0.1);
}

.flex-contents.dark-theme {
    background: var(--content-bg);
}

.flex-content.dark-theme {
    background: var(--content-bg);
}

/* Ensure tab containers inherit theme */
[data-theme="dark"] .flex-tabs {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .flex-tab {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .flex-tab:hover {
    background: #1e293b;
}

[data-theme="dark"] .flex-tab.active {
    background: var(--card-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .flex-contents {
    background: var(--content-bg);
}

[data-theme="dark"] .flex-content {
    background: var(--content-bg);
}

/* =================================
   SweetAlert Theme Support
================================= */

/* SweetAlert Overlay Theming */
.sweet-overlay[data-theme="dark"] {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.sweet-overlay[data-theme="light"] {
    background-color: rgba(0, 0, 0, 0.4) !important;
}

/* SweetAlert Modal Theming */
.sweet-alert[data-theme="dark"] {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

.sweet-alert[data-theme="light"] {
    background-color: #ffffff !important;
    color: #2d3748 !important;
    border: 1px solid #e0e0e0 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

/* SweetAlert Title Theming */
.sweet-alert[data-theme="dark"] h2 {
    color: var(--text-primary) !important;
}

.sweet-alert[data-theme="light"] h2 {
    color: #2d3748 !important;
}

/* SweetAlert Text Theming */
.sweet-alert[data-theme="dark"] p {
    color: var(--text-secondary) !important;
}

.sweet-alert[data-theme="light"] p {
    color: #4a5568 !important;
}

/* SweetAlert Button Theming */
.sweet-alert[data-theme="dark"] button {
    background: var(--primary-gradient) !important;
    color: var(--text-light) !important;
    border: 1px solid var(--primary-color) !important;
}

.sweet-alert[data-theme="dark"] button:hover {
    background: var(--secondary-color) !important;
    box-shadow: 0 4px 12px var(--focus-ring) !important;
}

.sweet-alert[data-theme="dark"] button.cancel {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.sweet-alert[data-theme="dark"] button.cancel:hover {
    background: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

/* SweetAlert Input Theming */
.sweet-alert[data-theme="dark"] input {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.sweet-alert[data-theme="dark"] input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px var(--focus-ring) !important;
}

/* SweetAlert2 (Swal2) Support */
.swal2-container[data-theme="dark"] {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.swal2-popup[data-theme="dark"] {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

.swal2-popup[data-theme="dark"] .swal2-title {
    color: var(--text-primary) !important;
}

.swal2-popup[data-theme="dark"] .swal2-content {
    color: var(--text-secondary) !important;
}

.swal2-popup[data-theme="dark"] .swal2-confirm {
    background: var(--primary-gradient) !important;
    border: 1px solid var(--primary-color) !important;
}

.swal2-popup[data-theme="dark"] .swal2-cancel {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.swal2-popup[data-theme="dark"] .swal2-input {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.swal2-popup[data-theme="dark"] .swal2-input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px var(--focus-ring) !important;
}

/* Theme-aware class-based styling for better compatibility */
.theme-dark .sweet-alert {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.theme-dark .sweet-overlay {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.theme-dark .swal2-popup {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.theme-dark .swal2-container {
    background-color: rgba(0, 0, 0, 0.8) !important;
}
