/* NetStacks GUI Custom Styles */

/* Menu Items Reordering Styles */
#menu-items-list .list-group-item {
    transition: background-color 0.2s;
    user-select: none;
}

#menu-items-list .list-group-item:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

#menu-items-list .list-group-item.sortable-ghost {
    opacity: 0.4;
    background-color: rgba(13, 110, 253, 0.1);
}

#menu-items-list .drag-handle {
    opacity: 0.4;
    transition: opacity 0.2s;
}

#menu-items-list .list-group-item:hover .drag-handle {
    opacity: 1;
}

#menu-items-list .toggle-visibility {
    padding: 0.25rem 0.5rem;
}

[data-bs-theme="dark"] #menu-items-list .list-group-item {
    background-color: #2a2a2a;
    border-color: #404040;
    color: #e0e0e0;
}

[data-bs-theme="dark"] #menu-items-list .list-group-item:hover {
    background-color: #333333;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.sidebar.collapsed {
    margin-left: -220px;
}

.sidebar .brand-header {
    padding: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.sidebar .brand-logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s;
}

.sidebar .brand-logo:hover {
    opacity: 0.8;
}

.sidebar .brand-logo i {
    font-size: 1.5rem;
    color: #3b82f6;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-section {
    margin-top: 8px;
}

.sidebar-section-header {
    padding: 8px 16px;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s;
    user-select: none;
}

.sidebar-section-header:hover {
    color: #94a3b8;
}

.sidebar-section-header i.chevron {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.sidebar-section.collapsed .sidebar-section-header i.chevron {
    transform: rotate(-90deg);
}

.sidebar-section-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.sidebar-section.collapsed .sidebar-section-content {
    max-height: 0;
    opacity: 0;
}

.sidebar .nav {
    padding: 0;
}

.sidebar .nav-item {
    margin: 0;
}

.sidebar .nav-link {
    color: #cbd5e1;
    padding: 8px 16px 8px 32px;
    font-size: 0.875rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(59, 130, 246, 0.15);
    border-left-color: #3b82f6;
    font-weight: 500;
}

.sidebar .nav-link i {
    width: 18px;
    font-size: 0.9rem;
    text-align: center;
}

.sidebar .user-info {
    padding: 12px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    margin-top: 8px;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, #0f172a 50%);
}

.sidebar .user-info .user-name {
    color: #e2e8f0;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar .user-info .user-name i {
    font-size: 0.75rem;
}

.sidebar .user-info .user-meta {
    color: #64748b;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.sidebar .user-info .user-meta i {
    font-size: 0.7rem;
}

.sidebar .user-info .btn-logout {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.sidebar .user-info .btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #fca5a5;
}

.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1050;
    background-color: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
    background-color: #334155;
    border-color: rgba(148, 163, 184, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle.sidebar-collapsed {
    left: 12px;
}

.sidebar-toggle:not(.sidebar-collapsed) {
    left: 232px;
}

.main-content {
    margin-left: 220px;
    padding: 20px;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Dark theme adjustments for sidebar */
[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
}

[data-bs-theme="dark"] .sidebar-toggle {
    background-color: #1e293b;
    border-color: rgba(148, 163, 184, 0.2);
}

/* Light theme adjustments */
[data-bs-theme="light"] .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: 1px solid #e2e8f0;
}

[data-bs-theme="light"] .sidebar .brand-logo {
    color: #0f172a;
}

[data-bs-theme="light"] .sidebar-section-header {
    color: #475569;
}

[data-bs-theme="light"] .sidebar-section-header:hover {
    color: #1e293b;
}

[data-bs-theme="light"] .sidebar .nav-link {
    color: #475569;
}

[data-bs-theme="light"] .sidebar .nav-link:hover {
    color: #0f172a;
    background-color: rgba(59, 130, 246, 0.08);
}

[data-bs-theme="light"] .sidebar .nav-link.active {
    color: #1e40af;
    background-color: rgba(59, 130, 246, 0.12);
}

[data-bs-theme="light"] .sidebar .user-info {
    border-top-color: #e2e8f0;
    background: linear-gradient(180deg, transparent 0%, #f8fafc 50%);
}

[data-bs-theme="light"] .sidebar .user-info .user-name {
    color: #0f172a;
}

[data-bs-theme="light"] .sidebar .user-info .user-meta {
    color: #64748b;
}

[data-bs-theme="light"] .sidebar-toggle {
    background-color: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
}

[data-bs-theme="light"] .sidebar-toggle:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

/* NetStacks GUI Custom Styles */

/* Custom dark theme with neutral grays (no pink tint) */
[data-bs-theme="dark"] {
    --bs-body-bg: #1a1a1a;
    --bs-body-color: #e0e0e0;
    --bs-card-bg: #2a2a2a;
    --bs-border-color: #404040;
}

[data-bs-theme="dark"] body {
    background-color: #1a1a1a;
}

[data-bs-theme="light"] body {
    background-color: #f8f9fa;
}

/* Override card backgrounds to pure gray */
[data-bs-theme="dark"] .card {
    background-color: #2a2a2a;
    border-color: #404040;
}

[data-bs-theme="dark"] .card-header {
    background-color: #333333;
    border-bottom: 2px solid #404040;
}

/* Form controls - neutral gray */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #333333;
    border-color: #404040;
    color: #e0e0e0;
}

/* Modals - neutral gray */
[data-bs-theme="dark"] .modal-content {
    background-color: #2a2a2a;
    border-color: #404040;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #404040;
}

/* Pre/code blocks - dark theme */
[data-bs-theme="dark"] pre {
    background-color: #2a2a2a;
    border-color: #404040;
    color: #e0e0e0;
}

/* Pre/code blocks - light theme */
[data-bs-theme="light"] pre {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

/* Service variables container - dark theme */
[data-bs-theme="dark"] .service-variables-container {
    background-color: #2a2a2a;
}

/* Service variables container - light theme */
[data-bs-theme="light"] .service-variables-container {
    background-color: #f8f9fa;
}

/* Alert/info boxes - neutral colors */
[data-bs-theme="dark"] .alert-info {
    background-color: #1a3a52;
    border-color: #2a5a7a;
    color: #a8d4f0;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: #4a3c1a;
    border-color: #6a5a2a;
    color: #f0d8a8;
}

[data-bs-theme="dark"] .alert-success {
    background-color: #1a3a2a;
    border-color: #2a5a3a;
    color: #a8f0c0;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: #4a1a1a;
    border-color: #6a2a2a;
    color: #f0a8a8;
}

[data-bs-theme="dark"] .alert-secondary {
    background-color: #2a2a2a;
    border-color: #404040;
    color: #c0c0c0;
}

/* Compact Navbar Styling */
.navbar {
    min-height: 48px;
}

.navbar .nav-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.navbar .navbar-nav {
    gap: 0.25rem;
}

/* Brand Logo Styling */
.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0.3rem 0.8rem;
    transition: all 0.3s ease;
}

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

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    border-radius: 8px;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 3px 10px rgba(13, 110, 253, 0.3);
    transition: all 0.3s ease;
}

.brand-logo:hover .brand-icon {
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.4);
    transform: rotate(-5deg);
}

.brand-text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

/* Template cards - compact styling */
.template-card .card-body {
    padding: 0.75rem;
}

.template-card .card-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.template-card .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
}

.template-card .template-flow {
    margin: 0.5rem 0;
}

.template-card .action-buttons {
    margin-top: 0.5rem;
}

.template-card p.text-muted {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

/* Standalone templates - even more compact */
.template-card-mini .card-body {
    padding: 0.5rem;
}

.template-card-mini .card-title {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.template-card-mini .badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.35rem;
}

.template-card-mini .template-flow {
    margin: 0.4rem 0;
}

.template-card-mini .action-buttons {
    margin-top: 0.4rem;
}

.template-card-mini p.text-muted {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
}

.template-card-mini .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.card-header {
    /* background-color removed - handled by dark theme override */
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
}

/* Status badges */
.badge-queued {
    background-color: #ffc107;
    color: #000;
}

.badge-running {
    background-color: #17a2b8;
}

.badge-completed {
    background-color: #28a745;
}

.badge-failed {
    background-color: #dc3545;
}

/* Task table */
#tasks-table tbody tr {
    cursor: pointer;
}

#tasks-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Code/pre styling */
pre {
    font-size: 0.875rem;
    background-color: #f8f9fa;
}

/* Loading spinner centering */
.spinner-border {
    margin: 2rem auto;
    display: block;
}

/* Stats cards */
.card.text-white h2 {
    font-weight: bold;
    margin: 0;
}

.card.text-white .card-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

/* Dashboard clickable cards */
.dashboard-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.25) !important;
}

/* Auto-refresh button */
#auto-refresh-btn.active {
    background-color: #0d6efd;
    color: white;
}

/* Form styling */
.form-label {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

textarea.font-monospace {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

/* Modal improvements */
.modal-xl {
    max-width: 90%;
}

.modal pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Quick action buttons */
.btn-lg {
    padding: 0.75rem 1.5rem;
}

/* Worker status colors */
.worker-idle {
    color: #6c757d;
}

.worker-busy {
    color: #0d6efd;
}

.worker-failed {
    color: #dc3545;
}

/* Responsive table */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

/* Alerts */
.alert {
    border-radius: 0.5rem;
}

/* Device select styling */
select.form-select {
    background-color: #fff;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Success/Error status panels */
#status-success .alert,
#status-error .alert {
    margin-bottom: 0;
}

/* Navigation active states */
.nav-link.active {
    font-weight: 600;
}

/* Search input styling - dark mode compatible */
.search-icon {
    background-color: transparent;
}

.search-input {
    background-color: transparent;
}

[data-bs-theme="dark"] .search-icon {
    background-color: #333333;
    border-color: #404040;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .search-input {
    background-color: #333333;
    border-color: #404040;
    color: #e0e0e0;
}

[data-bs-theme="light"] .search-icon {
    background-color: #ffffff;
    border-color: #dee2e6;
}

[data-bs-theme="light"] .search-input {
    background-color: #ffffff;
    border-color: #dee2e6;
}

/* Table dark mode support */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.075);
    color: #e0e0e0;
}

[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table > thead > tr > th {
    background-color: #333333 !important;
    color: #e0e0e0 !important;
    border-bottom: 2px solid #404040 !important;
}

[data-bs-theme="dark"] .table tbody tr {
    border-bottom: 1px solid #404040;
}

[data-bs-theme="dark"] .table tbody td {
    border-bottom: 1px solid #404040;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .table-secondary,
[data-bs-theme="dark"] .table .table-secondary {
    background-color: #2a2a2a !important;
    color: #c0c0c0 !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.075);
}

/* Utility classes */
.opacity-50 {
    opacity: 0.5;
}

.font-monospace {
    font-family: 'Courier New', Courier, monospace;
}

/* Config Backups / Devices page dark theme support */
[data-bs-theme="dark"] .card-footer {
    background-color: #333333;
    border-top: 1px solid #404040;
}

[data-bs-theme="dark"] .card-footer.bg-light {
    background-color: #333333 !important;
}

[data-bs-theme="dark"] .collapse .card-body.border-top {
    border-color: #404040 !important;
}

[data-bs-theme="dark"] #running-tasks-card {
    background-color: #2a2a2a;
    border-color: #404040;
}

[data-bs-theme="dark"] #running-tasks-card .card-header {
    background-color: #0d6efd !important;
}

[data-bs-theme="dark"] .pagination .page-link {
    background-color: #333333;
    border-color: #404040;
    color: #e0e0e0;
}

[data-bs-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: #2a2a2a;
    border-color: #404040;
    color: #6c757d;
}

[data-bs-theme="dark"] .btn-link {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .btn-link:hover {
    color: #9ec5fe;
}

/* Textarea in modals dark theme */
[data-bs-theme="dark"] textarea.form-control[readonly] {
    background-color: #1a1a1a;
    border-color: #404040;
    color: #e0e0e0;
}

/* ============================================================================
   Config Diff View Styles
   ============================================================================ */

.diff-line {
    display: flex;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    border-bottom: 1px solid #eee;
}

.diff-line-num {
    min-width: 40px;
    padding: 2px 8px;
    text-align: right;
    color: #999;
    background-color: #f8f9fa;
    border-right: 1px solid #ddd;
    user-select: none;
}

.diff-line-content {
    flex: 1;
    padding: 2px 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Added lines */
.diff-added {
    background-color: #d4edda;
}

.diff-added .diff-line-num {
    background-color: #c3e6cb;
    color: #155724;
}

.diff-added .diff-line-content {
    color: #155724;
}

/* Removed lines */
.diff-removed {
    background-color: #f8d7da;
}

.diff-removed .diff-line-num {
    background-color: #f5c6cb;
    color: #721c24;
}

.diff-removed .diff-line-content {
    color: #721c24;
    text-decoration: line-through;
    opacity: 0.8;
}

/* Unchanged lines */
.diff-unchanged {
    background-color: #fff;
}

/* Dark theme support for diff view */
[data-bs-theme="dark"] .diff-line {
    border-bottom-color: #404040;
}

[data-bs-theme="dark"] .diff-line-num {
    background-color: #2a2a2a;
    border-right-color: #404040;
    color: #888;
}

[data-bs-theme="dark"] .diff-unchanged {
    background-color: #1e1e1e;
}

[data-bs-theme="dark"] .diff-unchanged .diff-line-content {
    color: #d4d4d4;
}

[data-bs-theme="dark"] .diff-added {
    background-color: #1e3a1e;
}

[data-bs-theme="dark"] .diff-added .diff-line-num {
    background-color: #264f26;
    color: #8bcd8b;
}

[data-bs-theme="dark"] .diff-added .diff-line-content {
    color: #8bcd8b;
}

[data-bs-theme="dark"] .diff-removed {
    background-color: #3a1e1e;
}

[data-bs-theme="dark"] .diff-removed .diff-line-num {
    background-color: #4f2626;
    color: #cd8b8b;
}

[data-bs-theme="dark"] .diff-removed .diff-line-content {
    color: #cd8b8b;
}

[data-bs-theme="dark"] #diff-content-container {
    background-color: #1e1e1e;
    border-color: #404040 !important;
}
