/*--------------------------------------------------------------
# INTERACTIVE CALENDAR BOOKING MODAL
# Modern Agency Strategy Intake Popup (WordPress FSE Modular)
--------------------------------------------------------------*/

#tp-calendar-modal,
.tp-calendar-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);

  &.tp-cal-modal--bn {
    font-family: 'Hind Siliguri', var(--tp-ff-body, sans-serif);

    .tp-cal-modal-title,
    .tp-cal-section-label,
    .tp-cal-btn-text,
    .tp-cal-success-title,
    .tp-cal-btn-done,
    .tp-cal-current-month,
    .tp-cal-time-label,
    .tp-cal-field-label {
      font-family: 'Hind Siliguri', var(--tp-ff-heading, sans-serif);
    }
  }

  &#tp-calendar-modal.is-open,
  &.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 999999;

    .tp-cal-modal-dialog {
      transform: scale(1) translateY(0);
      opacity: 1;
    }
  }

  .tp-cal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    cursor: pointer;
  }

  .tp-cal-modal-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 860px;
    max-height: calc(100vh - 40px);
    display: flex;
    justify-content: center;
  }

  .tp-cal-modal-dialog {
    position: relative;
    width: 100%;
    background: #ffffff;
    border-radius: 28px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow:
      0 25px 60px -15px rgba(15, 23, 42, 0.18),
      0 0 1px 1px rgba(15, 23, 42, 0.04);
    padding: 36px 40px;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: calc(100vh - 40px);
    transform: scale(0.96) translateY(12px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);

    /* Custom smooth scrollbar */
    &::-webkit-scrollbar {
      width: 6px;
    }
    &::-webkit-scrollbar-thumb {
      background: #cbd5e1;
      border-radius: 999px;
    }
  }

  .tp-cal-modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;

    &:hover {
      background: #e2e8f0;
      color: #0f172a;
      transform: rotate(90deg);
    }
  }

  /* Header */
  .tp-cal-modal-header {
    margin-bottom: 28px;
    padding-right: 48px;

    .tp-cal-modal-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 5px 14px;
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 600;
      color: #2563eb;
      letter-spacing: 0.02em;
      margin-bottom: 12px;

      .tp-cal-modal-badge-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #2563eb;
        animation: tpPulseDot 2s infinite ease-in-out;
      }

      .tp-cal-modal-badge-duration {
        background: #2563eb;
        color: #ffffff;
        padding: 2px 8px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 700;
      }
    }

    .tp-cal-modal-title {
      font-family: var(--tp-ff-heading);
      font-size: clamp(22px, 3vw, 28px);
      font-weight: 700;
      color: #0f172a;
      line-height: 1.25;
      letter-spacing: -0.025em;
      margin: 0 0 6px 0;
    }

    .tp-cal-modal-subtitle {
      font-family: var(--tp-ff-body);
      font-size: 14px;
      color: #64748b;
      line-height: 1.5;
      margin: 0;
    }
  }

  /* Error Box */
  .tp-cal-modal-alert {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;

    &.tp-cal-modal-alert--error {
      background: #fef2f2;
      border: 1px solid #fecaca;
      color: #b91c1c;
    }
  }

  /* Split Layout */
  .tp-cal-modal-body-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    align-items: start;
  }

  .tp-cal-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--tp-ff-heading);
    font-size: 13.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #334155;
    margin-bottom: 18px;

    .tp-cal-step-num {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: #0f172a;
      color: #ffffff;
      font-size: 11px;
      font-weight: 800;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
  }

  /* Calendar Widget */
  .tp-cal-widget {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 18px 20px;
    margin-bottom: 22px;

    .tp-cal-widget-nav {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;

      .tp-cal-current-month {
        font-family: var(--tp-ff-heading);
        font-size: 15px;
        font-weight: 700;
        color: #0f172a;
        letter-spacing: -0.01em;
      }

      .tp-cal-nav-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        border: 1px solid #e2e8f0;
        background: #ffffff;
        color: #475569;
        font-size: 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;

        &:hover {
          background: #2563eb;
          border-color: #2563eb;
          color: #ffffff;
        }

        &:disabled {
          opacity: 0.4;
          cursor: not-allowed;
          background: #ffffff;
          border-color: #e2e8f0;
          color: #94a3b8;
        }
      }
    }

    .tp-cal-days-header {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      text-align: center;
      font-size: 11px;
      font-weight: 700;
      color: #94a3b8;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 10px;
    }

    .tp-cal-days-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 4px;

      .tp-cal-day-cell {
        aspect-ratio: 1;
        border-radius: 10px;
        border: none;
        background: transparent;
        color: #1e293b;
        font-family: var(--tp-ff-body);
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;

        &:hover:not(:disabled) {
          background: #dbeafe;
          color: #1d4ed8;
          transform: translateY(-1px);
        }

        &.is-today {
          border: 1px solid #93c5fd;
          color: #2563eb;
          font-weight: 700;
        }

        &.is-selected {
          background: #2563eb;
          color: #ffffff;
          font-weight: 700;
          box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
        }

        &:disabled {
          color: #cbd5e1;
          cursor: not-allowed;
          opacity: 0.55;
        }

        &.is-empty {
          cursor: default;
          visibility: hidden;
        }
      }
    }
  }

  /* Time Slots */
  .tp-cal-time-section {
    .tp-cal-time-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 12px;

      .tp-cal-time-label {
        font-size: 13px;
        font-weight: 700;
        color: #334155;
      }

      .tp-cal-tz-wrapper {
        position: relative;
        display: inline-flex;
        align-items: center;

        .tp-cal-tz-select {
          appearance: none;
          -webkit-appearance: none;
          background: #f1f5f9;
          border: 1px solid #e2e8f0;
          border-radius: 999px;
          padding: 3px 22px 3px 10px;
          font-family: var(--tp-ff-body);
          font-size: 11px;
          font-weight: 600;
          color: #334155;
          cursor: pointer;
          transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
          max-width: 175px;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;

          &:hover,
          &:focus {
            outline: none;
            border-color: #93c5fd;
            background: #eff6ff;
            color: #1d4ed8;
          }
        }

        .tp-cal-tz-chevron {
          position: absolute;
          right: 8px;
          pointer-events: none;
          color: #64748b;
        }
      }
    }

    /* Filter Pills: All, Morning, Afternoon, Night */
    .tp-cal-time-periods {
      display: flex;
      gap: 6px;
      margin-bottom: 12px;
      overflow-x: auto;
      padding-bottom: 2px;

      &::-webkit-scrollbar {
        height: 0;
        display: none;
      }

      .tp-cal-period-btn {
        padding: 5px 12px;
        border-radius: 999px;
        border: 1px solid #e2e8f0;
        background: #f8fafc;
        color: #64748b;
        font-family: var(--tp-ff-body);
        font-size: 11.5px;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.18s ease;

        &:hover {
          border-color: #cbd5e1;
          background: #ffffff;
          color: #1e293b;
        }

        &.is-active {
          background: #0f172a;
          border-color: #0f172a;
          color: #ffffff;
          box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
        }
      }
    }

    /* Scrollable Time Slots Grid */
    .tp-cal-time-slots {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      max-height: 195px;
      overflow-y: auto;
      padding-right: 4px;

      &::-webkit-scrollbar {
        width: 4px;
      }
      &::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 999px;
      }

      .tp-cal-time-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 6px;
        border-radius: 10px;
        border: 1px solid #e2e8f0;
        background: #ffffff;
        color: #334155;
        cursor: pointer;
        text-align: center;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

        .tp-cal-time-main {
          font-size: 12.5px;
          font-weight: 700;
          line-height: 1.2;
        }

        .tp-cal-time-sub {
          font-size: 10px;
          font-weight: 500;
          color: #94a3b8;
          margin-top: 2px;
          line-height: 1;
        }

        &:hover {
          border-color: #93c5fd;
          background: #eff6ff;
          color: #1d4ed8;

          .tp-cal-time-sub {
            color: #3b82f6;
          }
        }

        &.is-selected {
          background: #2563eb;
          border-color: #2563eb;
          color: #ffffff;
          box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);

          .tp-cal-time-sub {
            color: #dbeafe;
          }
        }

        &.is-hidden {
          display: none;
        }
      }

      .tp-cal-no-slots {
        grid-column: 1 / -1;
        padding: 20px 12px;
        text-align: center;
        color: #64748b;
        font-size: 12.5px;
        background: #f8fafc;
        border-radius: 10px;
        border: 1px dashed #e2e8f0;
      }
    }

    .tp-cal-tz-hint {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 10px;
      font-size: 11px;
      color: #64748b;

      svg {
        flex-shrink: 0;
        color: #059669;
      }
    }
  }

  /* Right Column: Details & Summary */
  .tp-cal-selected-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 18px;

    svg {
      color: #2563eb;
      flex-shrink: 0;
    }

    &.has-selection {
      background: #eff6ff;
      border-color: #bfdbfe;
      color: #1d4ed8;
    }
  }

  .tp-cal-form-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;

    .tp-cal-field-group {
      display: flex;
      flex-direction: column;
      gap: 5px;

      .tp-cal-field-label {
        font-size: 12px;
        font-weight: 600;
        color: #334155;
      }

      input,
      textarea {
        width: 100%;
        padding: 10px 14px;
        box-sizing: border-box;
        border-radius: 10px;
        border: 1px solid #e2e8f0;
        background: #f8fafc;
        font-family: var(--tp-ff-body);
        font-size: 13.5px;
        color: #0f172a;
        transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;

        &::placeholder {
          color: #94a3b8;
          font-size: 13px;
        }

        &:focus {
          outline: none;
          background: #ffffff;
          border-color: #2563eb;
          box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
        }
      }

      textarea {
        resize: vertical;
        min-height: 56px;
      }
    }
  }

  /* Submit Button & Actions */
  .tp-cal-action-area {
    .tp-cal-submit-button {
      width: 100%;
      padding: 14px 20px;
      border-radius: 999px;
      background: #2563eb;
      border: 1px solid #1d4ed8;
      color: #ffffff;
      font-family: var(--tp-ff-heading);
      font-size: 14.5px;
      font-weight: 700;
      letter-spacing: -0.01em;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      box-shadow: 0 10px 24px -4px rgba(37, 99, 235, 0.4);
      transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;

      .tp-cal-btn-arrow {
        transition: transform 0.2s ease;
      }

      &:hover:not(:disabled) {
        background: #1d4ed8;
        transform: translateY(-2px);
        box-shadow: 0 14px 30px -4px rgba(37, 99, 235, 0.5);

        .tp-cal-btn-arrow {
          transform: translateX(3px);
        }
      }

      &:disabled {
        opacity: 0.65;
        cursor: not-allowed;
      }

      .tp-cal-spinner {
        display: none;
        width: 16px;
        height: 16px;
        border: 2px solid rgba(255, 255, 255, 0.4);
        border-top-color: #ffffff;
        border-radius: 50%;
        animation: tpCalSpin 0.7s linear infinite;
      }

      &.is-loading {
        .tp-cal-spinner {
          display: inline-block;
        }
        .tp-cal-btn-arrow {
          display: none;
        }
      }
    }

    .tp-cal-privacy-notice {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-size: 11.5px;
      color: #94a3b8;
      margin: 10px 0 0 0;
      text-align: center;
    }
  }

  /* Success Confirmation View */
  .tp-cal-success-view {
    text-align: center;
    padding: 30px 20px;

    .tp-cal-success-icon-wrap {
      width: 76px;
      height: 76px;
      border-radius: 50%;
      background: #ecfdf5;
      color: #10b981;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto 20px auto;
      box-shadow: 0 10px 24px rgba(16, 185, 129, 0.2);
    }

    .tp-cal-success-title {
      font-family: var(--tp-ff-heading);
      font-size: 26px;
      font-weight: 700;
      color: #0f172a;
      letter-spacing: -0.02em;
      margin: 0 0 10px 0;
    }

    .tp-cal-success-desc {
      font-family: var(--tp-ff-body);
      font-size: 14.5px;
      color: #64748b;
      line-height: 1.6;
      max-width: 480px;
      margin: 0 auto 24px auto;
    }

    .tp-cal-success-slot-box {
      display: inline-block;
      padding: 12px 24px;
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      border-radius: 14px;
      font-size: 15px;
      color: #1d4ed8;
      margin-bottom: 28px;
    }

    .tp-cal-btn-done {
      padding: 12px 36px;
      border-radius: 999px;
      background: #0f172a;
      border: none;
      color: #ffffff;
      font-family: var(--tp-ff-heading);
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.2s ease, transform 0.2s ease;

      &:hover {
        background: #1e293b;
        transform: translateY(-1px);
      }
    }
  }
}

/* Animations */
@keyframes tpPulseDot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.5;
  }
}

@keyframes tpCalSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ==============================================================
   Mobile & Tablet Responsiveness (High-Specificity Responsive Grid)
   ============================================================== */
@media (max-width: 920px) {
  #tp-calendar-modal,
  .tp-calendar-modal {
    padding: 12px;

    .tp-cal-modal-container {
      width: 100%;
      max-width: 620px;
    }

    .tp-cal-modal-dialog {
      padding: 28px 22px 32px;
      border-radius: 24px;
      max-height: calc(100vh - 24px);
      max-height: calc(100dvh - 24px);
    }

    .tp-cal-modal-header {
      margin-bottom: 20px;
      padding-right: 44px;

      .tp-cal-modal-title {
        font-size: 22px;
      }

      .tp-cal-modal-subtitle {
        font-size: 13.5px;
      }
    }

    .tp-cal-modal-body-split {
      display: flex;
      flex-direction: column;
      gap: 28px;
    }

    .tp-cal-picker-col,
    .tp-cal-details-col {
      width: 100%;
    }

    .tp-cal-widget {
      padding: 16px;
      border-radius: 18px;
      margin-bottom: 18px;
    }

    .tp-cal-time-section .tp-cal-time-slots {
      grid-template-columns: repeat(3, 1fr);
      max-height: 220px;
    }
  }
}

@media (max-width: 640px) {
  #tp-calendar-modal,
  .tp-calendar-modal {
    padding: 10px 8px;

    .tp-cal-modal-container {
      max-width: 100%;
    }

    .tp-cal-modal-dialog {
      padding: 22px 16px 26px;
      border-radius: 20px;
      max-height: calc(100vh - 16px);
      max-height: calc(100dvh - 16px);
    }

    .tp-cal-modal-close {
      top: 12px;
      right: 12px;
      width: 36px;
      height: 36px;
    }

    .tp-cal-modal-header {
      margin-bottom: 16px;
      padding-right: 40px;

      .tp-cal-modal-badge {
        font-size: 11px;
        padding: 4px 10px;
        margin-bottom: 8px;
      }

      .tp-cal-modal-title {
        font-size: 20px;
        line-height: 1.3;
        margin-bottom: 6px;
      }

      .tp-cal-modal-subtitle {
        font-size: 13px;
        line-height: 1.5;
      }
    }

    .tp-cal-modal-body-split {
      gap: 22px;
    }

    .tp-cal-section-label {
      font-size: 13px;
      margin-bottom: 14px;

      .tp-cal-step-num {
        width: 20px;
        height: 20px;
        font-size: 10.5px;
      }
    }

    .tp-cal-widget {
      padding: 14px 12px;
      border-radius: 16px;
      margin-bottom: 16px;

      .tp-cal-widget-nav {
        margin-bottom: 12px;

        .tp-cal-current-month {
          font-size: 15px;
        }

        .tp-cal-nav-btn {
          width: 30px;
          height: 30px;
        }
      }

      .tp-cal-days-header {
        font-size: 11px;
        margin-bottom: 8px;
      }

      .tp-cal-days-grid {
        gap: 3px;

        .tp-cal-day-cell {
          font-size: 13.5px;
          border-radius: 8px;
        }
      }
    }

    .tp-cal-time-section {
      .tp-cal-time-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;

        .tp-cal-time-label {
          font-size: 13px;
        }

        .tp-cal-tz-wrapper {
          width: 100%;

          .tp-cal-tz-select {
            width: 100%;
            max-width: 100%;
            height: 36px;
            font-size: 12px;
          }
        }
      }

      .tp-cal-time-periods {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        margin-bottom: 12px;

        .tp-cal-period-btn {
          padding: 6px 2px;
          font-size: 11px;
          text-align: center;
        }
      }

      .tp-cal-time-slots {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        max-height: 200px;

        .tp-cal-time-btn {
          padding: 8px 4px;
          min-height: 46px;

          .tp-cal-time-main {
            font-size: 12px;
          }

          .tp-cal-time-sub {
            font-size: 9px;
          }
        }
      }
    }

    .tp-cal-selected-summary {
      padding: 10px 12px;
      font-size: 12px;
      margin-bottom: 14px;
      border-radius: 10px;
    }

    .tp-cal-form-fields {
      gap: 12px;
      margin-bottom: 16px;

      .tp-cal-field-group {
        gap: 4px;

        .tp-cal-field-label {
          font-size: 12px;
        }

        input,
        textarea {
          padding: 11px 13px;
          font-size: 15px;
          border-radius: 10px;
        }
      }
    }

    .tp-cal-action-area {
      .tp-cal-submit-button {
        padding: 13px 20px;
        font-size: 14.5px;
        min-height: 48px;
      }
    }
  }
}

@media (max-width: 420px) {
  #tp-calendar-modal,
  .tp-calendar-modal {
    .tp-cal-time-section .tp-cal-time-slots {
      grid-template-columns: repeat(2, 1fr);
    }
  }
}
