/* ===== Ramona CRM Main Styles ===== */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
}

/* ===== Layout ===== */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
  display: flex;
  flex-direction: column;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===== Sidebar Header ===== */
.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
}

.sidebar-brand i {
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ===== Sidebar Nav ===== */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  color: var(--bs-body-color);
  border-radius: 0;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover {
  background: var(--bs-tertiary-bg);
  color: var(--primary);
}

.sidebar-nav .nav-link.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  font-weight: 600;
  border-right: 3px solid var(--primary);
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 1.2rem;
  text-align: center;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bs-secondary-color);
  padding: 0.75rem 1.25rem 0.25rem;
  white-space: nowrap;
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--bs-border-color);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-details {
  min-width: 0;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--bs-body-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
}

/* ===== Search ===== */
.search-box {
  position: relative;
  min-width: 280px;
}

.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 9999;
  max-height: 400px;
  overflow-y: auto;
}

.search-results.visible {
  display: block;
}

.search-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  padding: 0.5rem 1rem 0.25rem;
  border-top: 1px solid var(--bs-border-color);
}

.search-group-label:first-child {
  border-top: none;
}

.search-result-item {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--bs-body-color);
  transition: background 0.1s;
}

.search-result-item:hover {
  background: var(--bs-tertiary-bg);
  color: var(--primary);
}

.search-result-item .result-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.search-result-item .result-sub {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

/* ===== Content Area ===== */
.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

/* ===== KPI Cards ===== */
.kpi-card {
  border-radius: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  margin-top: 0.25rem;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* ===== Status Badges ===== */
.badge-lead { background: #0dcaf0; color: #000; }
.badge-prospect { background: #ffc107; color: #000; }
.badge-kunde { background: #198754; color: #fff; }
.badge-inaktiv { background: #6c757d; color: #fff; }

/* ===== Cards ===== */
.crm-card {
  border-radius: 0.75rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

/* ===== Kanban Board ===== */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 70vh;
}

.kanban-column {
  min-width: 220px;
  max-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem 0.5rem 0 0;
  font-weight: 600;
  font-size: 0.85rem;
}

.kanban-column-body {
  background: var(--bs-tertiary-bg);
  border-radius: 0 0 0.5rem 0.5rem;
  padding: 0.5rem;
  flex: 1;
  min-height: 200px;
}

.kanban-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  transition: box-shadow 0.15s;
  position: relative;
}

.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kanban-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.kanban-column-body.drag-over {
  background: rgba(79, 70, 229, 0.08);
  border: 2px dashed var(--primary);
}

/* ===== Timeline for interactions ===== */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--bs-border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-icon {
  position: absolute;
  left: -2rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  background: var(--bs-body-bg);
  border: 2px solid var(--bs-border-color);
}

.timeline-content {
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bs-border-color);
}

/* ===== Priority colors ===== */
.priority-hoch { border-left: 4px solid #dc3545 !important; }
.priority-mittel { border-left: 4px solid #ffc107 !important; }
.priority-niedrig { border-left: 4px solid #0dcaf0 !important; }

/* ===== Mobile ===== */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .sidebar-overlay {
    display: none;
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1039;
}

/* ===== Sidebar collapsed labels ===== */
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-actions {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Overdue highlight ===== */
.overdue {
  border-left: 4px solid #dc3545 !important;
  background: rgba(220, 53, 69, 0.05);
}

.due-today {
  border-left: 4px solid #ffc107 !important;
  background: rgba(255, 193, 7, 0.05);
}

/* ===== Quick stats bar ===== */
.pipeline-progress {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

/* ===== Table improvements ===== */
.table-hover tbody tr:hover {
  cursor: pointer;
}

.table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
}

/* ===== Form improvements ===== */
.form-label {
  font-weight: 500;
  font-size: 0.875rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.2s ease;
}
