/* Beautiful Calendar Styles */

/* Prevent overflow issues during drag */
body.fc-dragging {
  overflow: visible !important;
}

html, body {
  overflow-x: visible;
}

/* Disable all animations during drag operations */
.fc-dragging * {
  transition: none !important;
  animation: none !important;
}

/* External draggable elements */
.fc-draggable-dragging {
  transition: none !important;
  animation: none !important;
  transform: none !important;
}

/* Calendar Page Layout */
.calendar-page-wrapper {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  position: relative;
  overflow: visible;

  .content {
    background: transparent;
    position: relative;
    overflow: visible;
  }

  .row {
    position: relative;
    overflow: visible;
  }

  .col-lg-3, .col-lg-9, .col-md-4, .col-md-8 {
    position: relative;
    overflow: visible;
  }
}

.calendar-page-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  }

  h3 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    text-align: center;

    @media (max-width: 768px) {
      font-size: 2rem;
    }
  }
}

.calendar-create-btn {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  border: none;
  border-radius: 50px;
  padding: 12px 30px;
  color: white;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  &:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 107, 107, 0.4);
    color: white;
    text-decoration: none;
  }

  &::before {
    content: "✨";
    font-size: 18px;
  }
}

/* Calendar Sidebar */
.calendar-sidebar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  z-index: 1;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  }

  h4 {
    color: #2c3e50;
    font-weight: 700;
    margin-bottom: 20px;
    font-size: 1.4rem;
    text-align: center;
  }

  #calendar-events {
    position: relative;
    z-index: 2;
  }
}

/* Calendar Events */
.calendar-events {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  color: white;
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 15px;
  cursor: move;
  transition: all 0.3s ease;
  border: none;
  box-shadow: 0 5px 15px rgba(116, 185, 255, 0.3);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
  }

  &:hover:not(.fc-dragging) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(116, 185, 255, 0.4);
    background: linear-gradient(135deg, #0984e3 0%, #74b9ff 100%);

    &::before {
      left: 100%;
    }
  }

  &:active {
    cursor: grabbing;
  }

  // Simple drag state - just hide the item completely
  &.dragging-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
    pointer-events: none !important;
  }
}

// Dropped Events Tracker Styling
.dropped-events-list {
  max-height: 300px;
  overflow-y: auto;

  .dropped-event-item {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 10px !important;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
      background: rgba(255, 255, 255, 1);
    }

    .badge {
      font-size: 10px;
      padding: 4px 8px;
      border-radius: 15px;
      text-transform: uppercase;
      font-weight: 600;

      &.bg-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; }
      &.bg-success { background: linear-gradient(135deg, #00b894 0%, #00cec9 100%) !important; }
      &.bg-warning { background: linear-gradient(135deg, #fdcb6e 0%, #e84393 100%) !important; }
      &.bg-danger { background: linear-gradient(135deg, #e17055 0%, #d63031 100%) !important; }
      &.bg-info { background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%) !important; }
      &.bg-secondary { background: linear-gradient(135deg, #636e72 0%, #2d3436 100%) !important; }
      &.bg-purple { background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%) !important; }
    }
  }
}

// Hide dragged items during drag
.calendar-events.dragging-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: none !important;
  pointer-events: none !important;
}

/* Calendar Events - Additional Styles */
.calendar-events {
  &[data-class="bg-success"] {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    box-shadow: 0 5px 15px rgba(0, 184, 148, 0.3);

    &:hover {
      background: linear-gradient(135deg, #00cec9 0%, #00b894 100%);
      box-shadow: 0 8px 25px rgba(0, 184, 148, 0.4);
    }

    &:active {
      background: linear-gradient(135deg, #00a085 0%, #00b8b3 100%);
    }
  }

  &[data-class="bg-danger"] {
    background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
    box-shadow: 0 5px 15px rgba(225, 112, 85, 0.3);

    &:hover {
      background: linear-gradient(135deg, #d63031 0%, #e17055 100%);
      box-shadow: 0 8px 25px rgba(225, 112, 85, 0.4);
    }

    &:active {
      background: linear-gradient(135deg, #c92a2a 0%, #d63031 100%);
    }
  }

  &[data-class="bg-warning"] {
    background: linear-gradient(135deg, #fdcb6e 0%, #e84393 100%);
    box-shadow: 0 5px 15px rgba(253, 203, 110, 0.3);

    &:hover {
      background: linear-gradient(135deg, #e84393 0%, #fdcb6e 100%);
      box-shadow: 0 8px 25px rgba(253, 203, 110, 0.4);
    }

    &:active {
      background: linear-gradient(135deg, #d63384 0%, #fab005 100%);
    }
  }

  i {
    margin-right: 10px;
    font-size: 12px;
  }

  // Drag states - simplified without problematic animations
  &.fc-dragging {
    opacity: 0.8 !important;
    z-index: 9999 !important;
    pointer-events: none !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    transition: none !important; // Disable transitions during drag
  }

  // Dragging state for external events
  &[data-is-dragging="true"] {
    opacity: 0.5;
    transition: none !important; // Disable transitions during drag
  }
}

// Let FullCalendar handle drag mirrors naturally
.fc-event-dragging,
.fc-event-mirror,
.fc-draggable-mirror {
  // Just hide them completely for clean experience
  display: none !important;
}

// Calendar drop zones
.fc-day-grid .fc-day.fc-highlight,
.fc-daygrid-day.fc-highlight {
  background: rgba(102, 126, 234, 0.1) !important;
  border: 2px dashed rgba(102, 126, 234, 0.5) !important;
  position: relative;

  &::before {
    content: '📅 Drop here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(102, 126, 234, 0.8);
    font-weight: 600;
    font-size: 12px;
    pointer-events: none;
  }
}

.fc-time-grid .fc-highlight {
  background: rgba(102, 126, 234, 0.1) !important;
  border: 2px dashed rgba(102, 126, 234, 0.5) !important;
}

/* Add Category Button */
.calendar-add-category-btn {
  background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
  border: none;
  border-radius: 50px;
  padding: 15px 25px;
  color: white;
  font-weight: 600;
  width: 100%;
  box-shadow: 0 8px 25px rgba(162, 155, 254, 0.3);
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  &:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(162, 155, 254, 0.4);
    color: white;
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    text-decoration: none;
  }
}

/* Calendar Main Card */
.calendar-main-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  z-index: 1;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  }

  .card-body {
    padding: 0;
    position: relative;
    overflow: visible;
  }
}

/* FullCalendar Beautiful Styling */
.fc {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.fc-toolbar-title {
  font-size: 2rem !important;
  font-weight: 700 !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;

  @media (max-width: 768px) {
    font-size: 1.5rem !important;
  }
}

.fc-button-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: none !important;
  border-radius: 10px !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important;
  transition: all 0.3s ease !important;

  &:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
  }

  &:not(:disabled):active,
  &:not(:disabled).fc-button-active {
    background: linear-gradient(135deg, #5a4fcf 0%, #667eea 100%) !important;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5) !important;
  }
}

.fc-daygrid-day {
  transition: all 0.3s ease;

  &:hover {
    background: rgba(102, 126, 234, 0.05) !important;
  }
}

.fc-day-today {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%) !important;
  border: 2px solid rgba(102, 126, 234, 0.3) !important;
  position: relative;

  &::before {
    content: '📅';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
    opacity: 0.7;
  }
}

.fc-event {
  border-radius: 8px !important;
  border: none !important;
  padding: 4px 8px !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  transition: all 0.3s ease !important;
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
  }

  &:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;

    &::before {
      left: 100%;
    }
  }

  &.bg-purple {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%) !important;
  }

  &.bg-success {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%) !important;
  }

  &.bg-info {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%) !important;
  }

  &.bg-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  }
}

.fc-daygrid-day-number {
  font-weight: 600 !important;
  color: #2c3e50 !important;
  padding: 8px !important;
  transition: all 0.3s ease;

  &:hover {
    color: #667eea !important;
    transform: scale(1.1);
  }
}

.fc-col-header-cell {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
  font-weight: 700 !important;
  color: #495057 !important;
  border: none !important;
  padding: 15px 8px !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fc-scrollgrid {
  border: none !important;
  border-radius: 15px !important;
  overflow: visible !important;
  position: relative;
  z-index: 1;
}

.fc-theme-standard td,
.fc-theme-standard th {
  border-color: rgba(0, 0, 0, 0.05) !important;
}

/* Checkbox Styling */
.checkbox {
  display: flex;
  align-items: center;
  margin-bottom: 15px;

  input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    margin-right: 8px;
    cursor: pointer;
  }

  label {
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    user-select: none;
  }
}

/* Modal Enhancements */
.modal.custom-modal {
  .modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
  }

  .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
    padding: 20px 25px;
    border-bottom: none;

    .modal-title {
      font-weight: 700;
      font-size: 1.3rem;
    }

    .btn-close {
      filter: brightness(0) invert(1);
      opacity: 0.8;

      &:hover {
        opacity: 1;
      }
    }
  }

  .modal-body {
    padding: 25px;
    background: rgba(255, 255, 255, 0.95);

    .form-group {
      margin-bottom: 20px;

      label {
        font-weight: 600;
        color: #2c3e50;
        margin-bottom: 8px;
        display: block;
      }

      .form-control {
        border-radius: 10px;
        border: 2px solid #e9ecef;
        padding: 12px 15px;
        transition: all 0.3s ease;

        &:focus {
          border-color: #667eea;
          box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }
      }
    }
  }

  .submit-section {
    text-align: center;
    margin-top: 30px;
  }

  .submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    padding: 12px 30px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    min-width: 150px;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
      background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    }

    &.btn-success {
      background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
      box-shadow: 0 8px 25px rgba(0, 184, 148, 0.3);

      &:hover {
        background: linear-gradient(135deg, #00cec9 0%, #00b894 100%);
        box-shadow: 0 12px 35px rgba(0, 184, 148, 0.4);
      }
    }

    &.btn-danger {
      background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
      box-shadow: 0 8px 25px rgba(225, 112, 85, 0.3);

      &:hover {
        background: linear-gradient(135deg, #d63031 0%, #e17055 100%);
        box-shadow: 0 12px 35px rgba(225, 112, 85, 0.4);
      }
    }
  }
}

/* Dark Mode Support */
[data-layout-mode="dark_mode"] {
  .calendar-page-wrapper {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  }

  .calendar-page-header {
    background: rgba(29, 29, 66, 0.95);
    border: 1px solid rgba(103, 116, 142, 0.3);

    h3 {
      background: linear-gradient(135deg, #ff9f43 0%, #feca57 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
  }

  .calendar-sidebar {
    background: rgba(29, 29, 66, 0.95);
    border: 1px solid rgba(103, 116, 142, 0.3);

    h4 {
      color: #ffffff;
    }
  }

  .calendar-main-card {
    background: rgba(29, 29, 66, 0.95);
    border: 1px solid rgba(103, 116, 142, 0.3);
  }

  .fc-col-header-cell {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
    color: #ffffff !important;
  }

  .fc-daygrid-day-number {
    color: #ffffff !important;

    &:hover {
      color: #ff9f43 !important;
    }
  }

  .fc-day-today {
    background: linear-gradient(135deg, rgba(255, 159, 67, 0.1) 0%, rgba(254, 202, 87, 0.1) 100%) !important;
    border: 2px solid rgba(255, 159, 67, 0.3) !important;
  }

  .fc-toolbar-title {
    background: linear-gradient(135deg, #ff9f43 0%, #feca57 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .fc-button-primary {
    background: linear-gradient(135deg, #ff9f43 0%, #feca57 100%) !important;
    box-shadow: 0 4px 15px rgba(255, 159, 67, 0.3) !important;

    &:hover {
      background: linear-gradient(135deg, #feca57 0%, #ff9f43 100%) !important;
      box-shadow: 0 6px 20px rgba(255, 159, 67, 0.4) !important;
    }

    &:not(:disabled):active,
    &:not(:disabled).fc-button-active {
      background: linear-gradient(135deg, #e8890a 0%, #ff9f43 100%) !important;
      box-shadow: 0 2px 10px rgba(255, 159, 67, 0.5) !important;
    }
  }

  .fc-daygrid-day:hover {
    background: rgba(255, 159, 67, 0.05) !important;
  }

  .modal.custom-modal {
    .modal-content {
      background: rgba(29, 29, 66, 0.95);
      border: 1px solid rgba(103, 116, 142, 0.3);
    }

    .modal-header {
      background: linear-gradient(135deg, #ff9f43 0%, #feca57 100%);
    }

    .modal-body {
      background: rgba(29, 29, 66, 0.95);

      .form-group {
        label {
          color: #ffffff;
        }

        .form-control {
          background: rgba(29, 29, 66, 0.8);
          border-color: rgba(103, 116, 142, 0.5);
          color: #ffffff;

          &:focus {
            border-color: #ff9f43;
            box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.1);
          }

          &::placeholder {
            color: rgba(255, 255, 255, 0.5);
          }
        }
      }
    }

    .submit-btn {
      background: linear-gradient(135deg, #ff9f43 0%, #feca57 100%);
      box-shadow: 0 8px 25px rgba(255, 159, 67, 0.3);

      &:hover {
        background: linear-gradient(135deg, #feca57 0%, #ff9f43 100%);
        box-shadow: 0 12px 35px rgba(255, 159, 67, 0.4);
      }
    }
  }

  .checkbox label {
    color: #ffffff;
  }

  // Dark mode drag & drop
  .fc-day-grid .fc-day.fc-highlight,
  .fc-daygrid-day.fc-highlight {
    background: rgba(255, 159, 67, 0.1) !important;
    border: 2px dashed rgba(255, 159, 67, 0.5) !important;

    &::before {
      color: rgba(255, 159, 67, 0.8) !important;
    }
  }

  .fc-time-grid .fc-highlight {
    background: rgba(255, 159, 67, 0.1) !important;
    border: 2px dashed rgba(255, 159, 67, 0.5) !important;
  }
}

/* Loading Animation */
@keyframes shimmer {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}

.calendar-loading {
  background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
  background-size: 800px 104px;
  animation: shimmer 1.5s infinite linear;
  border-radius: 15px;
  height: 400px;
}

/* Responsive Design */
@media (max-width: 992px) {
  .calendar-sidebar {
    margin-bottom: 30px;
  }
}

@media (max-width: 768px) {
  .calendar-page-wrapper {
    padding: 15px;
  }

  .calendar-page-header {
    padding: 20px;
    margin-bottom: 20px;
  }

  .calendar-sidebar {
    padding: 20px;
  }

  .calendar-main-card {
    padding: 20px;
  }

  .fc-toolbar {
    flex-direction: column;
    gap: 10px;

    .fc-toolbar-chunk {
      display: flex;
      justify-content: center;
    }
  }

  .calendar-events {
    padding: 12px;
    font-size: 14px;
  }
}

@media (max-width: 576px) {
  .calendar-page-header h3 {
    font-size: 1.8rem;
  }

  .calendar-create-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .fc-toolbar-title {
    font-size: 1.3rem !important;
  }

  .fc-button-primary {
    padding: 6px 12px !important;
    font-size: 12px !important;
  }
}