.calendar-admin {
  display: flex;
  gap: 24px;
  height: 80vh;
  min-height: 500px;

  aside {
    width: 320px;
    background: #f9f9f9;
    border-radius: 16px;
    padding: 20px;
    overflow-y: auto;

    h2 { 
      margin-bottom: 16px; 
      color: #008489;
      font-size: 1.3em;
    }

    ul { list-style: none; padding: 0; }

    .clinic-item {
      background: #fff;
      margin-bottom: 12px;
      border-radius: 12px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.04);
      overflow: hidden;
      transition: box-shadow 0.2s;
      --clinic-color: #008489; /* Default color */

      &:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
      }

      &.selected {
        border: 2px solid var(--clinic-color);
        box-shadow: 0 4px 12px color-mix(in srgb, var(--clinic-color) 15%, transparent);

        .clinic-info {
          background: color-mix(in srgb, var(--clinic-color) 10%, white);

          .clinic-name {
            color: var(--clinic-color);
            font-weight: 600;
          }
        }

        .clinic-arrow {
          color: var(--clinic-color);
        }
      }

      // Add a subtle left border with clinic color
      border-left: 3px solid var(--clinic-color);
    }

    .clinic-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      transition: background 0.2s;
    }

    .clinic-info {
      flex: 1;
      padding: 14px 16px;
      cursor: pointer;
      transition: background 0.2s;
      display: flex;
      flex-direction: column;
      gap: 4px;

      &:hover {
        background: #f5f5f5;
      }
    }

    .clinic-arrow {
      padding: 14px 16px;
      cursor: pointer;
      transition: transform 0.3s, background 0.2s, color 0.2s;
      color: var(--clinic-color, #008489);
      font-size: 0.9em;

      &:hover {
        background: #f5f5f5;
      }
    }

    .clinic-name {
      font-size: 1em;
      color: #222;
    }

    .office-count {
      font-size: 0.85em;
      color: #666;
    }

    .offices-list {
      background: color-mix(in srgb, var(--clinic-color, #008489) 3%, #f9f9f9);
      padding: 8px 0;
      margin: 0;
      border-left: 2px solid var(--clinic-color, #008489);
    }

    .office-item {
      padding: 0;
      margin: 0;
      background: transparent;
      box-shadow: none;
      border-radius: 0;
      border-bottom: 1px solid #eee;
      --clinic-color: #008489; /* Default color, inherited from parent */

      &:last-child {
        border-bottom: none;
      }

      &.selected {
        .office-info {
          background: color-mix(in srgb, var(--clinic-color) 10%, white);
          border-left: 3px solid var(--clinic-color);
          font-weight: 600;

          .office-details strong {
            color: var(--clinic-color);
          }
        }
      }
    }

    .office-info {
      display: flex;
      align-items: center;
      padding: 12px 16px;
      gap: 12px;
      cursor: pointer;
      transition: background 0.2s;
      border-left: 2px solid transparent;

      &:hover {
        background: color-mix(in srgb, var(--clinic-color) 5%, white);
        border-left-color: var(--clinic-color);
      }
    }

    .office-thumbnail {
      width: 48px;
      height: 48px;
      object-fit: cover;
      border-radius: 8px;
    }

    .office-thumbnail-placeholder {
      width: 48px;
      height: 48px;
      background: color-mix(in srgb, var(--clinic-color, #008489) 10%, white);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--clinic-color, #008489);
      font-size: 1.2em;
    }

    .office-details {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex: 1;

      strong {
        font-size: 0.95em;
        color: #222;
      }

      small {
        font-size: 0.85em;
        color: #666;
      }
    }

    .no-offices,
    .no-clinics {
      padding: 16px;
      text-align: center;
      color: #999;
      font-style: italic;
      background: transparent;
      box-shadow: none;
    }
  }

  .search-bar {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 1em;
  }

  .listing-img {
    width: 48px;
    height: 36px;
    background: #eee;
    margin-right: 12px;
    border-radius: 6px;
  }

  .calendar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    padding: 24px 18px;
    min-width: 0;
    height: 100%;

    .calendar-controls {
      display: flex;
      align-items: center;
      margin-bottom: 16px;
    }

    .calendar-month {
      flex: 1;
      text-align: center;
      font-size: 1.3em;
      font-weight: 600;
      color: #008489;

      .filter-indicator {
        font-size: 0.7em;
        color: #666;
        font-weight: 400;
        margin-left: 8px;
      }
    }

    .calendar-nav,
    .calendar-today,
    .calendar-clear-filter {
      background: #f7f7f7;
      border: none;
      border-radius: 8px;
      padding: 8px 14px;
      margin: 0 2px;
      font-size: 1em;
      cursor: pointer;
      transition: background 0.2s;
      text-decoration: none;
      color: #222;
      display: inline-block;

      &:hover { 
        background: #e0f7fa; 
        color: #008489;
      }
    }

    .calendar-clear-filter {
      background: #fff5f5;
      color: #ff6b6b;

      &:hover {
        background: #ffe0e0;
        color: #ff5252;
      }

      i {
        margin-right: 4px;
      }
    }

    .calendar-table-wrapper {
      flex: 1;
      display: flex;
      align-items: stretch;
      height: 100%;
      --clinic-color: #008489; /* Default color */
    }

    .calendar-table {
      width: 100%;
      height: 100%;
      border-collapse: separate;
      border-spacing: 8px;
      table-layout: fixed;

      th {
        padding: 8px 0;
        border-bottom: 1px solid #ccc;
        color: #008489;
        font-weight: 600;
        background: #f7f7f7;
        border-radius: 8px;
      }
    }

    .calendar-day-cell {
      background: #f9f9f9;
      border-radius: 12px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.03);
      min-width: 60px;
      height: 70px;
      vertical-align: top;
      position: relative;
      transition: box-shadow 0.2s, background 0.2s, border-color 0.2s;
      padding: 4px;

      &[data-date] {
        cursor: pointer;
      }

      &.has-reservations {
        background: color-mix(in srgb, var(--clinic-color) 8%, white);
        border: 1px solid color-mix(in srgb, var(--clinic-color) 30%, transparent);
      }

      &:hover { 
        box-shadow: 0 4px 16px color-mix(in srgb, var(--clinic-color) 10%, transparent); 
        background: color-mix(in srgb, var(--clinic-color) 5%, white); 
      }

      &.has-reservations:hover {
        background: color-mix(in srgb, var(--clinic-color) 12%, white);
        box-shadow: 0 4px 16px color-mix(in srgb, var(--clinic-color) 15%, transparent);
        border-color: color-mix(in srgb, var(--clinic-color) 40%, transparent);
      }

      &.today {
        background: color-mix(in srgb, var(--clinic-color) 10%, white);
        border: 2px solid var(--clinic-color);
      }

      &.other-month {
        opacity: 0.4;
      }

      .calendar-day-number {
        border-radius: 50%;
        display: inline-block;
        width: 32px;
        height: 32px;
        line-height: 32px;
        text-align: center;
      }

      &.today .calendar-day-number { 
        background: var(--clinic-color); 
        color: #fff; 
        font-weight: 600;
      }

      .reservations-indicator {
        position: absolute;
        bottom: 4px;
        right: 4px;
      }

      .reservation-badge {
        display: inline-block;
        background: var(--clinic-color);
        color: #fff;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        font-size: 0.75em;
        font-weight: 600;
        box-shadow: 0 2px 4px color-mix(in srgb, var(--clinic-color) 30%, transparent);
      }
    }

    .calendar-day-number {
      font-size: 1.2em;
      font-weight: 500;
      color: #222;
      margin-bottom: 4px;
      margin-top: 6px;
    }
  }
}

/* Reservation Modal */
.reservation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reservation-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.reservation-modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
}

.reservation-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
  background: #f9f9f9;

  h2 {
    margin: 0;
    font-size: 1.5em;
    color: #008489;
    font-weight: 600;
  }
}

.reservation-modal-close {
  background: none;
  border: none;
  font-size: 2em;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;

  &:hover {
    background: #eee;
    color: #222;
  }
}

.reservation-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.reservation-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  background: #f9f9f9;
  border-radius: 12px;
  border-left: 4px solid #008489;
  transition: box-shadow 0.2s;

  &:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  &:last-child {
    margin-bottom: 0;
  }
}

.reservation-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 8px;
  background: #e0f7fa;
  border-radius: 8px;

  i {
    color: #008489;
    font-size: 1.2em;
    margin-bottom: 4px;
  }

  strong {
    color: #008489;
    font-size: 1.1em;
    font-weight: 600;
  }
}

.reservation-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reservation-office {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  i {
    color: #666;
  }

  strong {
    color: #222;
    font-size: 1.1em;
  }

  .reservation-clinic {
    color: #666;
    font-size: 0.9em;
    margin-left: 4px;
  }
}

.reservation-customer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  i {
    color: #666;
  }

  span {
    color: #222;
  }

  .reservation-phone {
    color: #666;
    font-size: 0.9em;
    margin-left: 8px;
  }
}

.reservation-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.reservation-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: capitalize;

  &.status-pending {
    background: #fff3cd;
    color: #856404;
  }

  &.status-confirmed {
    background: #d4edda;
    color: #155724;
  }

  &.status-cancelled {
    background: #f8d7da;
    color: #721c24;
  }

  &.status-completed {
    background: #d1ecf1;
    color: #0c5460;
  }
}

.reservation-price {
  color: #008489;
  font-weight: 600;
  font-size: 1em;
}

.no-reservations {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 40px 20px;
}

/* Responsive */
@media (max-width: 900px) {
  .calendar-admin {
    flex-direction: column;
    height: auto;

    .calendar-section {
      padding: 12px 4px;

      .calendar-table {
        border-spacing: 4px;
      }

      .calendar-day-cell {
        min-width: 40px;
        height: 50px;
        padding: 2px;

        .calendar-day-number {
          font-size: 0.9em;
          margin-top: 2px;
          margin-bottom: 2px;
          width: 24px;
          height: 24px;
          line-height: 24px;
        }

        &.today .calendar-day-number {
          width: 24px;
          height: 24px;
          line-height: 24px;
        }

        .reservations-indicator {
          bottom: 2px;
          right: 2px;
        }

        .reservation-badge {
          width: 16px;
          height: 16px;
          line-height: 16px;
          font-size: 0.65em;
        }
      }
    }
  }

  .reservation-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .reservation-item {
    flex-direction: column;
    gap: 12px;
  }

  .reservation-time {
    flex-direction: row;
    justify-content: flex-start;
    min-width: auto;
    width: 100%;
  }
}
