﻿/* Admin theme customizations - Modern Enhanced Design */

/* ProfitMarginSettings — active rate row highlight (uses theme variables, works in light & dark) */
.profit-active-row {
    background-color: color-mix(in srgb, var(--site-accent) 15%, transparent) !important;
}

/* Clickable status badges (e.g. AiModels active/inactive toggle) */
.badge-toggle {
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
    user-select: none;
}

.badge-toggle:hover {
    opacity: 0.80;
    transform: scale(1.06);
}

.badge-toggle:active {
    transform: scale(0.97);
}

:root {
  --admin-sidebar-width: 260px;
  --admin-navbar-height: 56px;
  --admin-primary: #4f46e5;
  --admin-primary-dark: #4338ca;
  --admin-secondary: #7c3aed;
  --admin-success: #10b981;
  --admin-danger: #ef4444;
  --admin-warning: #f59e0b;
  --admin-info: #3b82f6;
  --admin-sidebar-bg: linear-gradient(180deg, #1a1d20 0%, #2d3748 100%);
  --admin-sidebar-hover: rgba(255, 255, 255, 0.15);
  --admin-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --admin-card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Reset html/body for admin area to override site.css */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Override site.css body margin for admin pages */
body {
  margin-bottom: 0 !important;
  background: #f8fafc;
}

/* Admin navbar - Modern gradient */
.admin-navbar {
  height: var(--admin-navbar-height);
  margin-right: var(--admin-sidebar-width);
  z-index: 1040;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: none;
}

.admin-navbar .navbar-brand {
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Fixed sidebar - Enhanced gradient */
.admin-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--admin-sidebar-width);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  background: linear-gradient(180deg, #1a1d20 0%, #2d3748 100%);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease-in-out;
}

/* Scrollbar styling for sidebar */
.admin-sidebar::-webkit-scrollbar {
  width: 6px;
}

.admin-sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.admin-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.admin-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Admin content wrapper */
.admin-content {
  display: flex;
  flex-direction: column;
  margin-top: var(--admin-navbar-height);
  margin-right: var(--admin-sidebar-width);
  min-height: calc(100vh - var(--admin-navbar-height));
  position: relative;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Main content */
.admin-content > main {
  flex: 1 1 auto;
  min-height: 200px;
  padding: 1.5rem;
  padding-bottom: 0.5rem;
}

/* Footer */
.admin-content > footer {
  position: relative !important;
  bottom: auto !important;
  width: auto !important;
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.75rem 0 0.5rem 0;
  line-height: 1.5 !important;
  z-index: 1;
  margin-bottom: 0;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.admin-content > footer .container-fluid,
.admin-content > footer .container {
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
  .admin-sidebar {
    transform: translateX(100%);
  }
  
  .admin-sidebar.show {
    transform: translateX(0);
  }
  
  .admin-content {
    margin-right: 0 !important;
  }
  
  .admin-navbar {
    margin-right: 0;
  }
  
  body.sidebar-open {
    overflow: hidden;
  }
}

/* Sidebar navigation styling - Enhanced */
.admin-sidebar .nav-link {
  color: #cbd5e1;
  border-radius: .5rem;
  padding: 0.65rem 0.85rem;
  margin: 0.15rem 0;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.admin-sidebar .nav-link::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--admin-primary);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.admin-sidebar .nav-link:hover {
  color: #fff;
  background: var(--admin-sidebar-hover);
  transform: translateX(-2px);
}

.admin-sidebar .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.3) 0%, rgba(124, 58, 237, 0.3) 100%);
  font-weight: 500;
}

.admin-sidebar .nav-link.active::before {
  transform: scaleY(1);
}

.admin-sidebar .nav-link.text-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.admin-sidebar .nav-link i {
  width: 1.5rem;
  text-align: center;
  margin-left: .5rem;
  transition: transform 0.2s ease;
}

.admin-sidebar .nav-link:hover i {
  transform: scale(1.1);
}

/* Section headers in sidebar */
.admin-sidebar .small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  color: #64748b;
}

/* Sidebar inner padding */
#adminSidebar .sidebar-inner {
  padding: 0;
}

/* Brand link styling */
.admin-sidebar a.border-bottom {
  border-color: rgba(255, 255, 255, 0.1) !important;
  background: rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
}

.admin-sidebar a.border-bottom:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Navbar brand visibility */
.navbar-brand {
  display: none;
}

@media (max-width: 991.98px) {
  .navbar-brand {
    display: block;
  }
}

/* Enhanced Cards */
.card {
  margin-bottom: 1.5rem;
  border: none;
  border-radius: 0.75rem;
  box-shadow: var(--admin-card-shadow);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--admin-card-shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  padding: 1rem 1.25rem;
}

/* Dashboard Stats Cards */
.card.border-0.shadow-sm {
  background: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.border-0.shadow-sm:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.15) !important;
}

/* Enhanced Buttons */
.btn {
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-dark) 100%);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--admin-primary-dark) 0%, #3730a3 100%);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--admin-success) 0%, #059669 100%);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--admin-danger) 0%, #dc2626 100%);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.btn-info {
  background: linear-gradient(135deg, var(--admin-info) 0%, #2563eb 100%);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-info:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, var(--admin-warning) 0%, #d97706 100%);
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  color: white;
}

.btn-warning:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-dark {
  background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
  box-shadow: 0 2px 4px rgba(55, 65, 81, 0.3);
}

.btn-dark:hover {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  box-shadow: 0 4px 8px rgba(55, 65, 81, 0.4);
  transform: translateY(-1px);
}

/* Enhanced Badges */
.badge {
  padding: 0.375rem 0.75rem;
  font-weight: 600;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.025em;
}

/* Enhanced Alerts */
.alert {
  border: none;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: var(--admin-card-shadow);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border-left: 4px solid var(--admin-success);
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  border-left: 4px solid var(--admin-danger);
}

.alert-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border-left: 4px solid var(--admin-warning);
}

.alert-info {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-left: 4px solid var(--admin-info);
}

/* Enhanced Tables */
.table {
  border-collapse: separate;
  border-spacing: 0;
}

.table thead {
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
}

.table thead th {
  border: none;
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 1rem 0.75rem;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
  background-color: #f8fafc;
  transform: scale(1.01);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(248, 250, 252, 0.5);
}

/* Enhanced Forms */
.form-control,
.form-select {
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Content spacing fixes */
.admin-content .container-fluid,
.admin-content .container {
  padding-bottom: 0.5rem;
}

/* Modal Enhancements */
.modal-content {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
  border-bottom: 2px solid #e5e7eb;
  border-radius: 1rem 1rem 0 0;
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 2px solid #e5e7eb;
  padding: 1rem 1.5rem;
}

/* Page Title Enhancement */
h1 {
  color: #1f2937;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--admin-primary);
  display: inline-block;
}

/* Clearfix */
.admin-content::after {
  content: "";
  display: table;
  clear: both;
}

/* Mehdi Custom Styles */
.ltr {
    direction: ltr;
    text-align: left;
}

/* Loading Animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fa-spinner.fa-spin {
  animation: spin 1s linear infinite;
}

/* ── Admin Dark Mode ─────────────────────────────────────────────────────── */
[data-theme="dark"] .admin-content,
[data-theme="dark"] body {
    background: #13141f;
    color: #dee2e6;
}

[data-theme="dark"] .admin-content > footer {
    background: #1a1b2e !important;
    border-color: #2d2f4a !important;
    color: #8892b8 !important;
}

[data-theme="dark"] .card,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer {
    background-color: #1e1f33 !important;
    border-color: #2d2f4a !important;
    color: #dee2e6 !important;
}

[data-theme="dark"] .card-header {
    background: linear-gradient(135deg, #1e1f33 0%, #272840 100%) !important;
    border-bottom-color: #2d2f4a !important;
}

[data-theme="dark"] .table,
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: #1e1f33 !important;
    color: #dee2e6 !important;
    border-color: #2d2f4a !important;
}

[data-theme="dark"] .table thead {
    background: linear-gradient(135deg, #272840 0%, #1e1f33 100%) !important;
}

[data-theme="dark"] .table-hover tbody tr:hover > * {
    background-color: #272840 !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(255, 255, 255, .03);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #272840 !important;
    border-color: #3e4060 !important;
    color: #dee2e6 !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #272840 !important;
    border-color: var(--admin-primary) !important;
}

[data-theme="dark"] .modal-content {
    background-color: #1e1f33 !important;
    border-color: #2d2f4a !important;
    color: #dee2e6 !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: #2d2f4a !important;
    background-color: #272840;
}

[data-theme="dark"] .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] h1 {
    color: #dee2e6;
}

[data-theme="dark"] .alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, .15) 0%, rgba(5, 150, 105, .1) 100%);
    color: #6ee7b7;
}

[data-theme="dark"] .alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, .15) 0%, rgba(220, 38, 38, .1) 100%);
    color: #fca5a5;
}

[data-theme="dark"] .alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, .15) 0%, rgba(217, 119, 6, .1) 100%);
    color: #fcd34d;
}

[data-theme="dark"] .alert-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, .15) 0%, rgba(37, 99, 235, .1) 100%);
    color: #93c5fd;
}

[data-theme="dark"] .badge.bg-secondary {
    background-color: #4a4e6d !important;
}

[data-theme="dark"] .input-group-text {
    background-color: #272840 !important;
    border-color: #3e4060 !important;
    color: #dee2e6 !important;
}

/* ── bg-light / pre / code overrides ────────────────────────────────────── */
/* Bootstrap's bg-light utility (#f8f9fa) is not theme-aware; override it   */
/* so code blocks and pre elements look correct in dark mode.                */

/* admin-code-bg: theme-aware replacement for Bootstrap's bg-light in code/pre blocks */
.admin-code-bg {
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
}

[data-theme="dark"] .bg-light {
    background-color: #272840 !important;
    color: #dee2e6 !important;
}

[data-theme="dark"] pre,
[data-theme="dark"] .admin-code-bg {
    background-color: #272840;
    border-color: #3e4060;
    color: #b0b8d8;
}

[data-theme="dark"] code {
    background-color: rgba(255, 255, 255, 0.07);
    color: #c4b5fd;
}

/* OS-level dark preference fallback */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .admin-content,
    :root:not([data-theme="light"]) body {
        background: #13141f;
        color: #dee2e6;
    }

    :root:not([data-theme="light"]) .admin-content > footer {
        background: #1a1b2e !important;
        border-color: #2d2f4a !important;
        color: #8892b8 !important;
    }

    :root:not([data-theme="light"]) .card,
    :root:not([data-theme="light"]) .card-header,
    :root:not([data-theme="light"]) .card-footer {
        background-color: #1e1f33 !important;
        border-color: #2d2f4a !important;
        color: #dee2e6 !important;
    }

    :root:not([data-theme="light"]) .table,
    :root:not([data-theme="light"]) .table > :not(caption) > * > * {
        background-color: #1e1f33 !important;
        color: #dee2e6 !important;
        border-color: #2d2f4a !important;
    }

    :root:not([data-theme="light"]) .table thead {
        background: linear-gradient(135deg, #272840 0%, #1e1f33 100%) !important;
    }

    :root:not([data-theme="light"]) .table-hover tbody tr:hover > * {
        background-color: #272840 !important;
    }

    :root:not([data-theme="light"]) .table-striped > tbody > tr:nth-of-type(odd) > * {
        --bs-table-accent-bg: rgba(255, 255, 255, .03);
    }

    :root:not([data-theme="light"]) .form-control,
    :root:not([data-theme="light"]) .form-select {
        background-color: #272840 !important;
        border-color: #3e4060 !important;
        color: #dee2e6 !important;
    }

    :root:not([data-theme="light"]) .modal-content {
        background-color: #1e1f33 !important;
        border-color: #2d2f4a !important;
        color: #dee2e6 !important;
    }

    :root:not([data-theme="light"]) .modal-header,
    :root:not([data-theme="light"]) .modal-footer {
        border-color: #2d2f4a !important;
        background-color: #272840;
    }

    :root:not([data-theme="light"]) .modal-header .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
    }

    :root:not([data-theme="light"]) h1 {
        color: #dee2e6;
    }

    :root:not([data-theme="light"]) .alert-success {
        background: linear-gradient(135deg, rgba(16, 185, 129, .15) 0%, rgba(5, 150, 105, .1) 100%);
        color: #6ee7b7;
    }

    :root:not([data-theme="light"]) .alert-danger {
        background: linear-gradient(135deg, rgba(239, 68, 68, .15) 0%, rgba(220, 38, 38, .1) 100%);
        color: #fca5a5;
    }

    :root:not([data-theme="light"]) .alert-warning {
        background: linear-gradient(135deg, rgba(245, 158, 11, .15) 0%, rgba(217, 119, 6, .1) 100%);
        color: #fcd34d;
    }

    :root:not([data-theme="light"]) .alert-info {
        background: linear-gradient(135deg, rgba(59, 130, 246, .15) 0%, rgba(37, 99, 235, .1) 100%);
        color: #93c5fd;
    }

    :root:not([data-theme="light"]) .badge.bg-secondary {
        background-color: #4a4e6d !important;
    }

    :root:not([data-theme="light"]) .input-group-text {
        background-color: #272840 !important;
        border-color: #3e4060 !important;
        color: #dee2e6 !important;
    }

    :root:not([data-theme="light"]) .bg-light {
        background-color: #272840 !important;
        color: #dee2e6 !important;
    }

    :root:not([data-theme="light"]) pre,
    :root:not([data-theme="light"]) .admin-code-bg {
        background-color: #272840;
        border-color: #3e4060;
        color: #b0b8d8;
    }

    :root:not([data-theme="light"]) code {
        background-color: rgba(255, 255, 255, 0.07);
        color: #c4b5fd;
    }
}