/* CalSchedule Custom Styles */

/* Fix dropdown z-index issues */
.dropdown-menu {
  z-index: 999999 !important;
  width: auto !important;
  min-width: 160px !important;
  max-width: 300px !important;
}

.dropdown.show .dropdown-menu {
  z-index: 999999 !important;
}

.dropdown-menu.show {
  z-index: 999999 !important;
}

/* Collapsible task hierarchy styles */
.task-details {
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.task-summary {
  list-style: none !important;
  position: relative;
}

.task-summary::-webkit-details-marker {
  display: none;
}

.task-summary::marker {
  display: none;
}

.task-children {
  margin-left: 0;
  border-left: 2px solid #e9ecef;
  padding-left: 15px;
  margin-top: 5px;
}

.collapse-indicator {
  transition: transform 0.2s ease;
}

.task-details[open] .collapse-indicator {
  transform: rotate(90deg);
}

.task-details:not([open]) .collapse-indicator {
  transform: rotate(0deg);
}

/* Global Styles */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8f9fa;
}

/* Navigation */
.navbar-brand {
  font-weight: bold;
  font-size: 1.5rem;
}

/* Cards */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

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

/* Feature Cards */
.feature-card {
  transition: all 0.3s ease;
  border-radius: 10px;
}

.feature-card:hover {
  background-color: #fff;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  transition: transform 0.3s ease;
}

.feature-card:hover .feature-icon {
  transform: scale(1.1);
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Task List Styles - High specificity to override Bootstrap */
.list-group-item.task-item {
  transition: all 0.3s ease;
  border: 2px solid transparent !important;
  margin-bottom: 2px;
  /* Background color will be set inline based on project area color */
}

.list-group-item.task-item:hover {
  border: 2px solid #007bff !important;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.25) !important;
  transform: translateY(-1px);
  /* Background color stays the same on hover */
}

.list-group-item.task-item.completed {
  opacity: 0.7;
  background-color: #f8f9fa !important;
}

.list-group-item.task-item.completed .task-title {
  text-decoration: line-through;
}

/* Task number badge styling */
.task-number {
  font-size: 0.8em;
  font-weight: 700;
  border: 1px solid #6c757d;
  background-color: #e9ecef !important;
  color: #495057 !important;
  min-width: 2.5rem;
  text-align: center;
}

/* Improve text contrast and readability */
.task-item .task-title a {
  color: #212529 !important; /* Darker text for better contrast */
  font-weight: 500;
}

.task-item .task-title a:hover {
  color: #007bff !important;
  text-decoration: none;
}

/* List group item override - but not for task items which have project area colors */
.list-group-item:not(.task-item) {
  background-color: #ffffff !important;
  border-color: #e9ecef !important;
}

.list-group-item:not(.task-item):hover {
  background-color: #f0f8ff !important; /* Light pastel blue */
}

/* Add Subtask button styling */
.task-item .btn-outline-success {
  opacity: 0;
  transition: opacity 0.3s ease;
  border: 1px solid #28a745;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
}

.task-item:hover .btn-outline-success {
  opacity: 1;
}

.task-item .btn-outline-success:hover {
  background-color: #28a745;
  color: white;
  transform: scale(1.05);
}

/* Task status indicator styling */
.task-status-indicator {
  pointer-events: none !important;
}

.task-status-indicator:hover {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  transform: none !important;
}

/* Familiarity control styling */
.familiarity-control {
  text-align: center;
}

.familiarity-label {
  font-size: 10px;
  color: #6c757d;
  font-weight: 500;
  white-space: nowrap;
}

.familiarity-buttons {
  justify-content: center;
}

.familiarity-btn {
  transition: all 0.2s ease;
  border-width: 1px !important;
}

.familiarity-btn:hover {
  transform: scale(1.1);
}

/* Covey matrix control styling */
.covey-matrix-control {
  display: inline-block;
}

.covey-matrix {
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
}

.covey-quadrant-btn {
  transition: all 0.2s ease;
  border: 1px solid #dee2e6 !important;
  line-height: 1;
}

.covey-quadrant-btn:hover {
  transform: scale(1.05);
  z-index: 1;
  position: relative;
}

/* Inline Subtask Form Styling */
#inline-subtask-form {
  animation: slideDown 0.3s ease-out;
}

#inline-subtask-form .card {
  border-color: #28a745;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

#inline-subtask-form .card-header {
  background-color: #f8fff9 !important;
  border-bottom-color: #28a745;
}

#inline-subtask-form .form-control:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

#inline-subtask-form .form-select:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Status Badges */
.status-completed {
  background-color: #28a745 !important;
}

.status-in-progress {
  background-color: #17a2b8 !important;
}

.status-pending {
  background-color: #6c757d !important;
}

.status-cancelled {
  background-color: #dc3545 !important;
}

/* Calendar Styles */
.calendar-container {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.fc-event:not(.slot-type-event) {
  border-radius: 5px;
  border: none;
  padding: 2px 5px;
  font-size: 0.85rem;
}

.fc-event.slot-type-event {
  border-radius: 5px;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.fc-daygrid-event {
  margin: 1px 0;
}

/* Drag and Drop Styles */
.task-list-item, .slot-type-item {
  cursor: move;
  transition: all 0.3s ease;
  border-radius: 5px;
  margin-bottom: 5px;
}

.task-list-item:hover, .slot-type-item:hover {
  background-color: #e9ecef;
  transform: scale(1.02);
  border: 2px solid #007bff;
}

.task-list-item.dragging, .slot-type-item.dragging {
  opacity: 0.7;
  transform: rotate(3deg) scale(1.05);
  border: 2px solid #007bff;
  box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* Drag feedback for slot types on calendar */
.fc-event.slot-type-event.fc-dragging {
  opacity: 0.8 !important;
  transform: rotate(2deg) !important;
  border-top-width: 3px !important;
  border-bottom-width: 3px !important;
  border-left-width: 1px !important;
  border-right-width: 1px !important;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3) !important;
}

/* Slot Type Events on Calendar */
/* Slot type events as frames/backgrounds */
.fc-event.slot-type-event {
  border-style: dashed !important;
  border-top-width: 1.5px !important;
  border-bottom-width: 1.5px !important;
  border-left-width: 0.5px !important;
  border-right-width: 0.5px !important;
  opacity: 0.8 !important;
  /* Force background color to be visible */
  background-color: var(--frame-color, #007bff) !important;
  background-image: linear-gradient(45deg, rgba(255,255,255,0.3) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0.3) 75%, transparent 75%) !important;
  background-size: 12px 12px !important;
  z-index: 1 !important;
  pointer-events: auto !important;
  border-radius: 6px !important;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.15) !important;
  /* Ensure frames take full width */
  width: 100% !important;
  left: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.fc-event.slot-type-event .fc-event-main {
  background-color: transparent !important;
  border: none !important;
  padding: 2px 4px !important;
  font-weight: bold !important;
  font-size: 0.7em !important;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.9) !important;
  color: #333 !important;
}

.fc-event.slot-type-event .fc-event-title {
  position: absolute !important;
  top: 2px !important;
  left: 1px !important;
  right: 1px !important;
  background: rgba(255,255,255,0.8) !important;
  padding: 1px 1px !important;
  border-radius: 2px !important;
  font-size: 0.65em !important;
  line-height: 1.2 !important;
}

/* Task events appear above slot types */
.fc-event:not(.slot-type-event) {
  z-index: 10 !important;
  position: relative !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
  border-radius: 4px !important;
}

/* Simplified approach - let FullCalendar handle positioning, just adjust margins */
.fc-event:not(.slot-type-event) {
  margin: 2px !important;
}

.fc-event.slot-type-event {
  margin: 0 !important;
}

/* Hover effects */
.fc-event.slot-type-event:hover {
  opacity: 0.6 !important;
  border-top-width: 3px !important;
  border-bottom-width: 3px !important;
  border-left-width: 1px !important;
  border-right-width: 1px !important;
  cursor: pointer !important;
}

.fc-event:not(.slot-type-event):hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
}

/* Resize handles for slot types */
.fc-event.slot-type-event .fc-event-resizer {
  display: block !important;
  background-color: rgba(0,0,0,0.4) !important;
  border: 1px solid rgba(0,0,0,0.6) !important;
  width: 100% !important;
  height: 6px !important;
  cursor: ns-resize !important;
  opacity: 0.7 !important;
}

.fc-event.slot-type-event .fc-event-resizer:hover {
  opacity: 1 !important;
  background-color: rgba(0,0,0,0.6) !important;
}

.fc-event.slot-type-event .fc-event-resizer-start {
  top: -3px !important;
}

.fc-event.slot-type-event .fc-event-resizer-end {
  bottom: -3px !important;
}

/* Selection highlighting */
.fc-event.selected {
  outline: 3px solid #007bff !important;
  outline-offset: 2px !important;
}

.fc-event.slot-type-event.selected {
  border-top-width: 4px !important;
  border-bottom-width: 4px !important;
  border-left-width: 1.5px !important;
  border-right-width: 1.5px !important;
  opacity: 0.8 !important;
  outline: 3px solid #007bff !important;
  outline-offset: 1px !important;
}

/* Click area improvements */
.fc-event.slot-type-event {
  min-height: 20px !important;
}

.fc-event.slot-type-event .fc-event-main {
  min-height: 100% !important;
  display: flex !important;
  align-items: flex-start !important;
}

/* Minimum height for task events to ensure task names are always visible */
.fc-event:not(.slot-type-event) {
  min-height: 40px !important; /* Equivalent to 30 minutes at standard FullCalendar scale */
}

.fc-event:not(.slot-type-event) .fc-event-main {
  min-height: 100% !important;
  display: flex !important;
  align-items: flex-start !important;
  padding: 2px 4px !important;
}

.fc-event:not(.slot-type-event) .fc-event-title {
  font-size: 0.85rem !important;
  line-height: 1.2 !important;
  overflow: hidden !important;
  white-space: normal !important; /* Allow text wrapping */
  word-wrap: break-word !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important; /* Limit to 2 lines for minimum height */
  -webkit-box-orient: vertical !important;
}

/* Ensure proper layering without interfering with FullCalendar positioning */
.fc-event.slot-type-event {
  /* Frames stay in background */
  z-index: 1 !important;
}

.fc-event:not(.slot-type-event) {
  /* Tasks appear above frames */
  z-index: 10 !important;
}

/* Ultra-high specificity CSS to override FullCalendar's inline styles */
html body .fc .fc-view .fc-timegrid .fc-timegrid-body .fc-timegrid-slots .fc-timegrid-slot .fc-timegrid-col .fc-timegrid-col-events .fc-timegrid-event-harness .fc-event.slot-type-event {
  width: 100% !important;
  left: 0 !important;
  right: auto !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  border-top-width: 1.5px !important;
  border-bottom-width: 1.5px !important;
  border-left-width: 0.5px !important;
  border-right-width: 0.5px !important;
  border-style: dashed !important;
  transform: none !important;
}

html body .fc .fc-view .fc-timegrid .fc-timegrid-body .fc-timegrid-slots .fc-timegrid-slot .fc-timegrid-col .fc-timegrid-col-events .fc-timegrid-event-harness .fc-event:not(.slot-type-event) {
  width: calc(100% - 6px) !important;
  left: 3px !important;
  right: auto !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  transform: none !important;
}

/* Additional ultra-specific selectors for any possible FullCalendar structure */
.fc-event.fc-timegrid-event.fc-v-event:not(.slot-type-event) {
  width: calc(100% - 6px) !important;
  left: 3px !important;
  margin: 0 !important;
  transform: none !important;
}

.fc-event.fc-timegrid-event.fc-v-event.slot-type-event {
  width: 100% !important;
  left: 0 !important;
  margin: 0 !important;
  transform: none !important;
  border-top-width: 1.5px !important;
  border-bottom-width: 1.5px !important;
  border-left-width: 0.5px !important;
  border-right-width: 0.5px !important;
  border-style: dashed !important;
}

/* Nuclear option - force container to not use FullCalendar's positioning */
.fc-timegrid-col-events {
  position: relative !important;
}

.fc-timegrid-col-events .fc-timegrid-event-harness {
  position: absolute !important;
  width: 100% !important;
  left: 0 !important;
}

.fc-timegrid-col-events .fc-timegrid-event-harness .fc-event:not(.slot-type-event) {
  position: absolute !important;
  width: calc(100% - 6px) !important;
  left: 3px !important;
  margin: 0 !important;
  transform: none !important;
}

.fc-timegrid-col-events .fc-timegrid-event-harness .fc-event.slot-type-event {
  position: absolute !important;
  width: 100% !important;
  left: 0 !important;
  margin: 0 !important;
  transform: none !important;
}

/* Override FullCalendar's inset property specifically */
.fc-timegrid-event-harness > .fc-timegrid-event:not(.slot-type-event) {
  inset: auto !important;
  left: 3px !important;
  right: 3px !important;
  top: 0 !important;
  bottom: 0 !important;
  width: calc(100% - 6px) !important;
  position: absolute !important;
}

.fc-timegrid-event-harness > .fc-timegrid-event.slot-type-event {
  inset: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  position: absolute !important;
  border-top-width: 1.5px !important;
  border-bottom-width: 1.5px !important;
  border-left-width: 0.5px !important;
  border-right-width: 0.5px !important;
  border-style: dashed !important;
}

.fc-event.slot-type-event:hover {
  opacity: 1;
}

.drop-zone {
  min-height: 100px;
  border: 2px dashed #dee2e6;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.drop-zone.drag-over {
  border-color: #007bff;
  background-color: rgba(0, 123, 255, 0.1);
}

/* Unscheduled Task List Styling */
.task-list-item {
  transition: all 0.2s ease;
  cursor: grab;
  border-radius: 8px !important;
}

.task-list-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border-color: #007bff !important;
}

.task-list-item:active {
  cursor: grabbing;
}

/* Task Drag and Drop Styling */
.task-draggable {
  transition: all 0.2s ease;
  cursor: grab;
}

.task-draggable:active {
  cursor: grabbing;
}

.task-draggable.dragging {
  opacity: 0.6;
  transform: rotate(2deg) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
  border: 2px solid #007bff !important;
  z-index: 1000;
}

.task-item.valid-drop-target {
  border: 2px dashed #28a745 !important;
  background-color: rgba(40, 167, 69, 0.1) !important;
  transform: scale(1.02);
}

.task-item.invalid-drop-target {
  border: 2px dashed #dc3545 !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
  opacity: 0.6;
}

.task-item.drop-hover {
  border: 3px solid #007bff !important;
  background-color: rgba(0, 123, 255, 0.15) !important;
  transform: scale(1.05);
}

.task-list-item .task-number {
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  min-width: 2rem !important;
  text-align: center !important;
  background-color: #e9ecef !important;
  color: #495057 !important;
  border: 1px solid #6c757d !important;
}

/* Covey Matrix Styles */
.covey-quadrant {
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 20px;
  min-height: 200px;
}

.covey-q1 {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: white;
}

.covey-q2 {
  background: linear-gradient(135deg, #4ecdc4, #44a08d);
  color: white;
}

.covey-q3 {
  background: linear-gradient(135deg, #feca57, #ff9ff3);
  color: white;
}

.covey-q4 {
  background: linear-gradient(135deg, #a8edea, #fed6e3);
  color: #333;
}

/* Form Styles */
.form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-select:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Loading Spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-section h1 {
    font-size: 2.5rem;
  }
  
  .feature-card {
    margin-bottom: 30px;
  }
  
  .calendar-container {
    padding: 10px;
  }
  
  .fc-toolbar {
    flex-direction: column;
  }
  
  .fc-toolbar-chunk {
    margin: 5px 0;
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Utility Classes */
.text-shadow {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.bg-gradient-primary {
  background: linear-gradient(135deg, #007bff, #0056b3);
}

.bg-gradient-success {
  background: linear-gradient(135deg, #28a745, #1e7e34);
}

.bg-gradient-warning {
  background: linear-gradient(135deg, #ffc107, #e0a800);
}

.bg-gradient-danger {
  background: linear-gradient(135deg, #dc3545, #c82333);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #ffffff;
  }
  
  .card {
    background-color: #2d2d2d;
    color: #ffffff;
  }
  
  .bg-light {
    background-color: #2d2d2d !important;
  }
  
  .text-muted {
    color: #adb5bd !important;
  }
}

/* Force 24-hour format for datetime inputs */
.datetime-24h::-webkit-datetime-edit-ampm-field {
  display: none !important;
}

.datetime-24h::-webkit-datetime-edit-hour-field {
  color: inherit;
}

input[type="datetime-local"].datetime-24h {
  /* Try to force 24-hour format */
  -webkit-locale: "en-GB";
}
