/* Main Styles */
:root {
  /* Light Theme (default) */
  --background-color: #f8f9fa;
  --text-color: #212529;
  --card-bg: #ffffff;
  --card-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  --border-color: rgba(0, 0, 0, 0.125);
  --hover-bg: rgba(0, 0, 0, 0.03);
  --input-bg: #f8f9fa;
  --navbar-bg: #ffffff;
  --navbar-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --sidebar-bg: linear-gradient(135deg, #0d6efd, #084298);
  --sidebar-text: #fff;
  --sidebar-link: rgba(255, 255, 255, 0.75);
  --sidebar-link-hover: rgba(255, 255, 255, 0.1);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --category-scrollbar-track: rgba(255, 255, 255, 0.1);
  --category-scrollbar-thumb: rgba(255, 255, 255, 0.3);
  --category-scrollbar-thumb-hover: rgba(255, 255, 255, 0.5);
}

/* Dark Theme */
.dark-mode {
  --background-color: #121212;
  --text-color: #e0e0e0;
  --card-bg: #1e1e1e;
  --card-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  --border-color: rgba(255, 255, 255, 0.05);
  --hover-bg: rgba(255, 255, 255, 0.05);
  --input-bg: #2d2d2d;
  --navbar-bg: #1e1e1e;
  --navbar-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  --sidebar-bg: linear-gradient(135deg, #084298, #052c65);
  --sidebar-text: #fff;
  --sidebar-link: rgba(255, 255, 255, 0.75);
  --sidebar-link-hover: rgba(255, 255, 255, 0.1);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --category-scrollbar-track: rgba(0, 0, 0, 0.3);
  --category-scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --category-scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
}

/* Add theme toggle switch styles */
.theme-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-left: 10px;
}

.theme-toggle input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.theme-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.dark-mode .theme-toggle-slider {
  background-color: #0d6efd;
}

.dark-mode .theme-toggle-slider:before {
  transform: translateX(20px);
}

/* Apply theme variables to elements */
body {
  background-color: var(--background-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
  height: 100vh;
  margin: 0;
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex-grow: 0;
  overflow-y: initial;
  padding-top: 15px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-nav .nav-link {
  color: var(--sidebar-link);
  padding: 10px 15px;
  margin: 0 10px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: 0.3s;
}

.sidebar-nav .nav-link i {
  margin-right: 10px;
  font-size: 1.1rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  color: white;
  background-color: var(--sidebar-link-hover);
}

.sidebar-footer {
  padding: 15px;
  border-top: 1px solid var(--sidebar-border);
  background: linear-gradient(135deg, #0d6efd, #084298);
  width: 100%;
  z-index: 100;
  position: absolute;
  bottom: 0;
  left: 0;
  flex-shrink: 0;
}

.sidebar-category-header {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 15px 25px 5px;
  margin-top: 15px;
  font-weight: 600;
  position: relative;
}

.sidebar-category-header:after {
  content: '';
  position: absolute;
  left: 25px;
  right: 25px;
  top: 5px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* Spezifischer Fix für die Scrollbarkeit der Kategorien */
#categoryNavLinks {
  width: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 115px; /* Platz für die Footer-Buttons */
  margin-bottom: 0;
  max-height: calc(100vh - 230px);
  -webkit-overflow-scrolling: touch; /* Verbessert Scrolling auf iOS */
  scrollbar-width: thin; /* Für Firefox */
  position: relative; /* Für absolute positionierte Elemente innerhalb */
  flex-grow: 1; /* Nimmt verfügbaren Platz ein */
}

/* Scrollbar-Stil für die Kategorien */
#categoryNavLinks::-webkit-scrollbar {
  width: 5px;
}

#categoryNavLinks::-webkit-scrollbar-track {
  background: var(--category-scrollbar-track);
  border-radius: 3px;
}

#categoryNavLinks::-webkit-scrollbar-thumb {
  background: var(--category-scrollbar-thumb);
  border-radius: 3px;
}

#categoryNavLinks::-webkit-scrollbar-thumb:hover {
  background: var(--category-scrollbar-thumb-hover);
}

/* Verbesserte Darstellung der Kategorien */
#categoryNavLinks .nav-link {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: left;
  padding: 8px 15px;
  margin: 1px 10px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  border-radius: 5px;
  transition: all 0.2s ease;
}

#categoryNavLinks .nav-link:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateX(2px);
}

#categoryNavLinks .nav-item {
  width: 100%;
  margin-bottom: 1px;
}

#categoryNavLinks .category-name {
  display: inline-block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

/* Verbesserte Sidebar-Struktur */
.sidebar-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px);
  overflow: hidden;
  position: relative;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.navbar {
  padding: 0.5rem 1rem;
  box-shadow: var(--navbar-shadow);
  background-color: var(--navbar-bg) !important;
  color: var(--text-color);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Stat Cards */
.stat-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  height: 100%;
  position: relative;
}

.stat-card-body {
  padding: 20px;
  position: relative;
}

.stat-card-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0;
}

.stat-card-icon {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 2.5rem;
  opacity: 0.3;
}

/* Category distribution */
.category-bar {
  height: 25px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.category-bar-label {
  width: 110px;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.category-bar-count {
  margin-left: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Recent Links List */
.recent-link-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s;
}

.recent-link-item:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.recent-link-icon {
  width: 35px;
  height: 35px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: white;
}

.recent-link-info {
  flex: 1;
  min-width: 0;
}

.recent-link-title {
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-link-details {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  color: #6c757d;
}

.recent-link-category {
  margin-right: 10px;
}

.recent-link-date {
  margin-left: auto;
}

/* Card Styles */
.card {
  background-color: var(--card-bg);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
  transition: transform 0.3s, box-shadow 0.3s;
  margin-bottom: 20px;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.card-body {
  padding: 1rem;
}

.card-body[data-url]:hover {
  background-color: rgba(13, 110, 253, 0.03);
}

.card-body[data-url] {
  cursor: pointer;
  position: relative;
}

.card-body[data-url]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background-color: transparent;
  transition: background-color 0.2s;
}

.card-body[data-url]:hover::after {
  background-color: #0d6efd;
}

.card-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.card-description {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  height: 2.8rem;
  font-size: 0.85rem;
  color: #6c757d;
}

.card-footer {
  background-color: transparent;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 0.5rem 1rem;
}

/* Link favicon */
.link-favicon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 2px;
}

/* Card header with favicon */
.card-header-with-favicon {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.link-category {
  font-size: 0.75rem;
  background-color: #e9ecef;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: inline-block;
  color: #495057;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.link-date {
  font-size: 0.75rem;
  color: #6c757d;
}

.btn-edit, .btn-delete {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Custom card colors based on category */
.category-work {
  border-top: 3px solid #0d6efd;
}

.category-personal {
  border-top: 3px solid #198754;
}

.category-education {
  border-top: 3px solid #6f42c1;
}

.category-entertainment {
  border-top: 3px solid #fd7e14;
}

.category-shopping {
  border-top: 3px solid #dc3545;
}

.category-default {
  border-top: 3px solid #adb5bd;
}

/* Category colors for icons */
.bg-category-work {
  background-color: #0d6efd;
}

.bg-category-personal {
  background-color: #198754;
}

.bg-category-education {
  background-color: #6f42c1;
}

.bg-category-entertainment {
  background-color: #fd7e14;
}

.bg-category-shopping {
  background-color: #dc3545;
}

.bg-category-default {
  background-color: #adb5bd;
}

/* Modal styling for dark mode */
.dark-mode .modal-content {
  background-color: var(--card-bg);
  color: var(--text-color);
}

.dark-mode .form-control, .dark-mode .form-select {
  background-color: var(--input-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.dark-mode .input-group-text {
  background-color: var(--input-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.dark-mode .list-group-item {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.dark-mode .table {
  color: var(--text-color);
}

.dark-mode .dropdown-menu {
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

.dark-mode .dropdown-item {
  color: var(--text-color);
}

.dark-mode .dropdown-item:hover {
  background-color: var(--hover-bg);
}

/* Category color customization */
.category-color-preview {
  width: 20px;
  height: 20px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.category-color-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px;
}

.color-option {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.color-option:hover, .color-option.selected {
  transform: scale(1.2);
  border: 2px solid #fff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* Dynamic category colors */
[data-category-color] {
  background-color: attr(data-category-color);
}

/* Custom category colors */
.category-work {
  border-top: 3px solid #0d6efd;
}

.category-personal {
  border-top: 3px solid #198754;
}

.category-education {
  border-top: 3px solid #6f42c1;
}

.category-entertainment {
  border-top: 3px solid #fd7e14;
}

.category-shopping {
  border-top: 3px solid #dc3545;
}

.category-default {
  border-top: 3px solid #adb5bd;
}

/* Responsive Design Improvements */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: -250px;
    z-index: 1040;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    height: 100%;
  }
  
  .sidebar.active {
    left: 0;
  }
  
  .main-content {
    width: 100%;
    margin-left: 0;
  }
  
  body.sidebar-active {
    overflow: hidden;
  }
  
  .overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  body.sidebar-active .overlay {
    opacity: 1;
    visibility: visible;
  }
  
  /* Verbesserte Scrollbarkeit der Kategorien auf mobilen Geräten */
  #categoryNavLinks {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 140px; /* Mehr Platz für Footer-Buttons auf Mobilgeräten */
    touch-action: pan-y; /* Verbessert touch-handling auf mobilen Geräten */
  }
  
  /* Verbesserte Anzeige der Kategorie-Namen auf mobilen Geräten */
  #categoryNavLinks .nav-link {
    padding: 10px 15px; /* Größere Touch-Fläche */
    margin: 2px 10px;
  }
  
  #categoryNavLinks .category-name {
    max-width: 180px; /* Mehr Platz für den Text */
  }
  
  /* Sidebar-Footer anpassen für mobile Geräte */
  .sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 10px;
    background-color: rgba(8, 66, 152, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
  }
}

@media (max-width: 768px) {
  .card-description {
    -webkit-line-clamp: 2; /* Weniger Zeilen auf kleineren Geräten */
  }
  
  .link-category {
    font-size: 0.7rem;
  }
  
  .stat-card {
    height: auto;
  }
  
  .stat-card-body {
    padding: 10px;
  }
  
  .stat-card-value {
    font-size: 1.5rem;
  }
  
  .stat-card-icon {
    font-size: 1.5rem;
  }
  
  /* Navbar-Verbesserungen für mobile Ansicht */
  .navbar .container-fluid {
    padding-left: 5px;
    padding-right: 5px;
  }
  
  .navbar .form-control {
    max-width: 150px;
  }
  
  /* Footer-Buttons besser stacken auf sehr kleinen Geräten */
  .sidebar-footer .btn {
    margin-bottom: 5px;
    padding: 8px;
    font-size: 0.9rem;
  }
  
  /* Optimierte Anzeige der Kategorienamen */
  #categoryNavLinks .category-name {
    max-width: 180px; /* Mehr Platz für den Text */
  }
}

/* Extra small devices */
@media (max-width: 576px) {
  .dashboard-container {
    flex-direction: column;
  }
  
  .content {
    padding: 10px !important;
  }
  
  .stat-card-title {
    font-size: 0.9rem;
  }
  
  .stat-card-value {
    font-size: 1.3rem;
  }
  
  /* Optimierungen für sehr kleine Geräte */
  #categoryNavLinks {
    max-height: calc(100vh - 200px);
  }
  
  .sidebar-footer {
    padding: 8px;
  }
  
  .sidebar-footer .btn {
    font-size: 0.8rem;
    padding: 6px;
  }
}

/* Spezifisches Fix für iOS Safari und andere mobile Browser */
@supports (-webkit-touch-callout: none) {
  #categoryNavLinks {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Verhindert unerwünschtes Ziehen/Scrolling des Viewports */
  .sidebar {
    touch-action: pan-y;
  }
}

/* Hierarchical Category Navigation */
.category-nav-list {
  width: 100%;
}

.category-sublist {
  padding-left: 0;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.category-sublist.expanded {
  display: block;
  max-height: none;
  overflow: visible;
}

.category-link {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  border-radius: 0.25rem;
  transition: all 0.2s;
  justify-content: flex-start;
}

.category-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.category-link.active {
  background-color: rgba(255, 255, 255, 0.2);
  font-weight: 500;
}

.category-link .bi {
  width: 20px;
  text-align: center;
  margin-right: 8px;
}

.category-link .bi-folder {
  color: #ffca2c;
}

.category-link .bi-tag {
  color: #6ea8fe;
}

.category-toggle {
  color: rgba(255, 255, 255, 0.5);
  padding: 0.2rem;
  border-radius: 3px;
  transition: color 0.15s ease-in-out;
  margin-left: auto;
}

.category-toggle:hover {
  color: rgba(255, 255, 255, 0.9);
  background-color: rgba(255, 255, 255, 0.1);
}

/* Ensure enough space for category navigation */
#categoryNavLinks {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 350px);
  min-height: 100px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
} 