/* ===========================================
   GESTIOLEX - Dark Mode Theme
   Bootstrap 5.3+ usa data-bs-theme="dark"
   =========================================== */

/* ===========================================
   TOGGLE BUTTON NAVBAR
   =========================================== */
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.8);
  transition: transform 0.3s ease, color 0.2s;
}

.theme-toggle:hover {
  color: white;
  transform: scale(1.1);
}

.theme-toggle:focus {
  outline: none;
}

/* Icona sole/luna */
.theme-toggle .theme-icon-light,
.theme-toggle .theme-icon-dark {
  display: none;
}

/* Light mode: mostra luna */
[data-bs-theme="light"] .theme-toggle .theme-icon-dark {
  display: inline;
}

/* Dark mode: mostra sole */
[data-bs-theme="dark"] .theme-toggle .theme-icon-light {
  display: inline;
}

/* ===========================================
   SIDEBAR - DARK MODE OVERRIDES
   =========================================== */
[data-bs-theme="dark"] {
  --sidebar-bg: #1a1d21;
  --sidebar-border: #2d3339;
  --sidebar-text: #adb5bd;
  --sidebar-hover: #2d3339;
  --sidebar-active: #4dd0e1;
}

[data-bs-theme="dark"] .app-sidebar {
  background-color: var(--sidebar-bg);
  border-right-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .sidebar-nav .nav-link {
  color: var(--sidebar-text);
}

[data-bs-theme="dark"] .sidebar-nav .nav-link:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-active);
}

[data-bs-theme="dark"] .sidebar-nav .nav-link.active {
  background-color: rgba(77, 208, 225, 0.1);
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
}

[data-bs-theme="dark"] .sidebar-divider {
  border-top-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .sidebar-section-title,
[data-bs-theme="dark"] .sidebar-section-header {
  color: #6c757d;
}

[data-bs-theme="dark"] .sidebar-version {
  color: #6c757d;
  background: linear-gradient(to bottom, transparent, var(--sidebar-bg));
}

/* Ricerca sidebar dark */
[data-bs-theme="dark"] .sidebar-search {
  border-bottom-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .sidebar-search input {
  background-color: #2d3339;
  border-color: #3d4349;
  color: #e9ecef;
}

[data-bs-theme="dark"] .sidebar-search input::placeholder {
  color: #6c757d;
}

[data-bs-theme="dark"] .sidebar-search input:focus {
  border-color: var(--sidebar-active);
  box-shadow: 0 0 0 2px rgba(77, 208, 225, 0.2);
}

[data-bs-theme="dark"] .sidebar-search-dropdown {
  background: #212529;
  border-color: #3d4349;
}

[data-bs-theme="dark"] .sidebar-search-section {
  background: #1a1d21;
  border-bottom-color: #2d3339;
  color: #6c757d;
}

[data-bs-theme="dark"] .sidebar-search-item {
  color: #e9ecef;
  border-bottom-color: #2d3339;
}

[data-bs-theme="dark"] .sidebar-search-item:hover {
  background: rgba(77, 208, 225, 0.1);
  color: var(--sidebar-active);
}

/* Recenti/Preferiti dark */
[data-bs-theme="dark"] .sidebar-recent-item,
[data-bs-theme="dark"] .sidebar-favorite-item {
  color: #adb5bd !important;
}

[data-bs-theme="dark"] .sidebar-recent-item:hover,
[data-bs-theme="dark"] .sidebar-favorite-item:hover {
  color: var(--sidebar-active) !important;
  background: var(--sidebar-hover);
}

/* ===========================================
   COMMAND PALETTE - DARK MODE
   =========================================== */
[data-bs-theme="dark"] .command-palette {
  background: #212529;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .command-palette-header {
  background: #1a1d21;
  border-bottom-color: #3d4349;
}

[data-bs-theme="dark"] .command-palette-input {
  color: #e9ecef;
}

[data-bs-theme="dark"] .command-palette-input::placeholder {
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-icon {
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-shortcut kbd {
  background: #3d4349;
  border-color: #4d5359;
  color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-section-title {
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-item:hover {
  background-color: #2d3339;
}

[data-bs-theme="dark"] .command-palette-item.selected {
  background-color: rgba(77, 208, 225, 0.15);
  outline-color: var(--sidebar-active);
}

[data-bs-theme="dark"] .command-palette-item-icon {
  background: #2d3339;
}

[data-bs-theme="dark"] .command-palette-item-icon.action {
  background: rgba(37, 99, 235, 0.2);
}

[data-bs-theme="dark"] .command-palette-item-icon.pratica {
  background: rgba(217, 119, 6, 0.2);
}

[data-bs-theme="dark"] .command-palette-item-icon.persona {
  background: rgba(5, 150, 105, 0.2);
}

[data-bs-theme="dark"] .command-palette-item-icon.evento {
  background: rgba(180, 83, 9, 0.2);
}

[data-bs-theme="dark"] .command-palette-item-title {
  color: #e9ecef;
}

[data-bs-theme="dark"] .command-palette-item-subtitle {
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-item-badge {
  background: #3d4349;
  color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-footer {
  background: #1a1d21;
  border-top-color: #3d4349;
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-footer-hint kbd {
  background: #2d3339;
  border-color: #3d4349;
  color: #adb5bd;
}

[data-bs-theme="dark"] .command-palette-empty,
[data-bs-theme="dark"] .command-palette-loading {
  color: #6c757d;
}

[data-bs-theme="dark"] .command-palette-highlight {
  background: rgba(254, 240, 138, 0.3);
  color: #fef08a;
}

/* ===========================================
   BODY & GENERAL OVERRIDES
   =========================================== */
[data-bs-theme="dark"] body.bg-light {
  background-color: #121416 !important;
}

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

/* Cards */
[data-bs-theme="dark"] .card {
  background-color: #212529;
  border-color: #3d4349;
}

[data-bs-theme="dark"] .card-header {
  background-color: #1a1d21;
  border-bottom-color: #3d4349;
}

[data-bs-theme="dark"] .card-footer {
  background-color: #1a1d21;
  border-top-color: #3d4349;
}

/* Tables */
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  color: #e9ecef;
}

[data-bs-theme="dark"] .table-bordered {
  border-color: #3d4349;
}

[data-bs-theme="dark"] .table thead th {
  border-bottom-color: #3d4349;
}

[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table th {
  border-color: #2d3339;
}

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #2d3339;
  border-color: #3d4349;
  color: #e9ecef;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #2d3339;
  border-color: #4dd0e1;
  color: #e9ecef;
  box-shadow: 0 0 0 0.2rem rgba(77, 208, 225, 0.25);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: #6c757d;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly] {
  background-color: #1a1d21;
}

[data-bs-theme="dark"] .input-group-text {
  background-color: #2d3339;
  border-color: #3d4349;
  color: #adb5bd;
}

/* List groups */
[data-bs-theme="dark"] .list-group-item {
  background-color: #212529;
  border-color: #3d4349;
  color: #e9ecef;
}

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

[data-bs-theme="dark"] .list-group-item.active {
  background-color: #0B5E70;
  border-color: #0B5E70;
}

/* Modals */
[data-bs-theme="dark"] .modal-content {
  background-color: #212529;
  border-color: #3d4349;
}

[data-bs-theme="dark"] .modal-header {
  border-bottom-color: #3d4349;
}

[data-bs-theme="dark"] .modal-footer {
  border-top-color: #3d4349;
}

[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dropdowns */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: #212529;
  border-color: #3d4349;
}

[data-bs-theme="dark"] .dropdown-item {
  color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: #2d3339;
  color: #fff;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-top-color: #3d4349;
}

[data-bs-theme="dark"] .dropdown-header {
  color: #6c757d;
}

/* Alerts */
[data-bs-theme="dark"] .alert-info {
  background-color: rgba(13, 202, 240, 0.15);
  border-color: rgba(13, 202, 240, 0.3);
  color: #6edff6;
}

[data-bs-theme="dark"] .alert-warning {
  background-color: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.3);
  color: #ffda6a;
}

[data-bs-theme="dark"] .alert-danger {
  background-color: rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.3);
  color: #ea868f;
}

[data-bs-theme="dark"] .alert-success {
  background-color: rgba(25, 135, 84, 0.15);
  border-color: rgba(25, 135, 84, 0.3);
  color: #75b798;
}

/* Breadcrumb */
[data-bs-theme="dark"] .breadcrumb {
  background-color: transparent;
}

[data-bs-theme="dark"] .breadcrumb-item a {
  color: #4dd0e1;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
  color: #adb5bd;
}

/* Nav tabs */
[data-bs-theme="dark"] .nav-tabs {
  border-bottom-color: #3d4349;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: #adb5bd;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  border-color: #3d4349;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background-color: #212529;
  border-color: #3d4349 #3d4349 #212529;
  color: #e9ecef;
}

/* Pills */
[data-bs-theme="dark"] .nav-pills .nav-link {
  color: #adb5bd;
}

[data-bs-theme="dark"] .nav-pills .nav-link.active {
  background-color: #0B5E70;
}

/* Badges */
[data-bs-theme="dark"] .badge.bg-light {
  background-color: #3d4349 !important;
  color: #e9ecef !important;
}

[data-bs-theme="dark"] .badge.bg-secondary {
  background-color: #4d5359 !important;
}

/* Text utilities */
[data-bs-theme="dark"] .text-muted {
  color: #6c757d !important;
}

[data-bs-theme="dark"] .text-dark {
  color: #e9ecef !important;
}

[data-bs-theme="dark"] .text-body {
  color: #e9ecef !important;
}

/* Borders */
[data-bs-theme="dark"] .border {
  border-color: #3d4349 !important;
}

[data-bs-theme="dark"] .border-bottom {
  border-bottom-color: #3d4349 !important;
}

[data-bs-theme="dark"] .border-top {
  border-top-color: #3d4349 !important;
}

/* Shadows - più sottili in dark mode */
[data-bs-theme="dark"] .shadow,
[data-bs-theme="dark"] .shadow-sm {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3) !important;
}

/* ===========================================
   NOTIFICATIONS DROPDOWN
   =========================================== */
[data-bs-theme="dark"] .notifications-dropdown {
  background-color: #212529;
  border-color: #3d4349;
}

/* ===========================================
   AI WIDGET
   =========================================== */
[data-bs-theme="dark"] .ai-widget-container {
  background-color: #212529;
  border-color: #3d4349;
}

/* ===========================================
   AUTOSAVE INDICATOR
   =========================================== */
[data-bs-theme="dark"] .autosave-indicator {
  color: #6c757d;
}

/* ===========================================
   SCROLLBARS (dark)
   =========================================== */
[data-bs-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track {
  background: #1a1d21;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #3d4349;
  border-radius: 4px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #4d5359;
}

/* ===========================================
   TRANSITION SMOOTH
   =========================================== */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

body,
.app-sidebar,
.card,
.modal-content,
.dropdown-menu,
.form-control,
.form-select {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
