:root {
    --primary-blue: #006bff;
    --light-blue: #e8f2ff;
    --text-dark: #1a202c;
    --text-muted: #718096;
    --border-color: #edf2f7;
    --bg-gray: #f8fafc;
}

* { box-sizing: border-box; }

.fsd-booking-body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f7ff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    color: var(--text-dark);
    margin: 0;
}

.main-title {
    align-self: flex-start;
    max-width: 900px;
    margin: 0 auto 20px auto;
    font-size: 2rem;
    color: #0d3b66;
    width: 100%;
}

.booking-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 720px;
    min-height: 0;
    height: auto; /* allow the card to grow so lead form doesn't get clipped */
    overflow: visible;
    border: 1px solid var(--border-color);
}

/* --- LEFT SIDEBAR --- */
.sidebar {
    width: 22%;
    padding: 16px;
    border-right: 1px solid var(--border-color);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.logo-box { width: 28px; height: 28px; background: var(--primary-blue); border-radius: 6px; transform: rotate(-10deg); }
    
.profile img { border-radius: 50%; width: 45px; margin-bottom: 10px; border: 2px solid white; outline: 1px solid #ddd; }
.profile .name { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.profile h2 { margin: 5px 0 25px 0; font-size: 1.5rem; }

.details { color: var(--text-muted); font-size: 0.95rem; line-height: 2; margin-bottom: 30px; }
    
.placeholders .line { height: 8px; background: #f1f5f9; border-radius: 10px; margin-bottom: 10px; }
.line.s { width: 50%; } .line.m { width: 80%; } .line.l { width: 70%; }

/* --- CENTER CALENDAR --- */
.calendar-container {
    /* flexible center column: grows to fill available space, but keeps a sensible minimum */
    flex: 1 1 0;
    padding: 12px;
    border-right: 1px solid var(--border-color);
    text-align: center;
    box-sizing: border-box;
    min-width: 220px;
}
.calendar-header { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0; }
.arrow { 
    cursor: pointer; width: 22px; height: 22px; display: flex; align-items: center; 
    justify-content: center; border-radius: 50%; color: var(--primary-blue); 
}
.arrow:hover { background: var(--light-blue); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.grid-label { font-size: 0.65rem; font-weight: bold; color: var(--text-muted); padding-bottom: 8px; }
    
.day {
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    font-size: 0.8rem;
    border-radius: 50%;
    transition: 0.18s;
}

.day.available {
    background-color: var(--light-blue);
    color: var(--primary-blue);
    font-weight: bold;
    cursor: pointer;
}

.day.available:hover { background-color: #d0e4ff; }

.day.selected {
    background-color: var(--primary-blue) !important;
    color: white !important;
}

.day.inactive { color: #cbd5e0; }

.timezone-footer { margin-top: 30px; font-size: 0.8rem; color: var(--text-dark); cursor: pointer; }

/* --- RIGHT TIME SLOTS --- */
.time-slots-container {
    width: 28%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* keep header fixed; only #slotsList should scroll */
    height: 100%;
    box-sizing: border-box;
}

/* make only the slots list scrollable so the date header remains visible */
#slotsList {
    overflow-y: auto;
    flex: 1 1 auto;
    /* constrain by viewport so it always scrolls within the page
       leave room for header/sidebar; adjust value if needed */
    max-height: calc(100vh - 420px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* give some inner padding so slot buttons breathe */
#slotsList { padding: 8px; }

/* make sure the scrollbar area can grow to the card height */
.booking-card > .time-slots-container,
.booking-card > section.time-slots-container {
    height: 100%;
}

/* custom scrollbar for webkit browsers (optional) - apply to the actual scrolling element */
#slotsList::-webkit-scrollbar { width: 10px; }
#slotsList::-webkit-scrollbar-track { background: transparent; }
#slotsList::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 6px; }

/* allow the slots column to shrink properly in flex layout */
.time-slots-container, #slotsList { min-height: 0; }

/* enable smooth scrolling on mobile */
#slotsList { -webkit-overflow-scrolling: touch; }

.time-slots-container h3 { font-size: 0.95rem; margin-bottom: 8px; }

/* Start/End controls in the time header kept on a single row */
.time-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
    flex-wrap: nowrap; /* keep items on one line */
}
.time-control-item {
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* allow flex items to shrink properly */
    flex: 0 1 auto; /* allow shrinking to avoid scrollbar */
}
.reset-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--primary-blue);
    cursor: pointer;
    padding: 6px 8px;
    white-space: nowrap;
    flex: 0 0 auto;
}

/* Ensure controls remain visible on small screens but can scroll horizontally */
@media (max-width: 480px) {
    .time-controls { gap: 6px; }
    .time-control-item { font-size: 0.85rem; }
    .reset-btn { padding: 6px; }
}

.slot-btn {
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 1px solid rgba(0,107,255,0.12);
    color: var(--primary-blue);
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    box-shadow: 0 2px 6px rgba(3,102,214,0.04);
    text-align: left;
}

.slot-btn:hover {
    background: #f3f9ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(3,102,214,0.06);
}

.confirm-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.confirm-wrapper .slot-btn {
    background: #2d3748;
    color: #fff;
    border: none;
    flex: 1;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.confirm-action-btn {
    background: linear-gradient(90deg, #006bff 0%, #0056e0 100%);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    flex: 0 0 auto;
    min-width: 140px;
    box-shadow: 0 6px 18px rgba(3,102,214,0.22);
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.confirm-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(3,102,214,0.28);
}

.confirm-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(3,102,214,0.20);
}

/* Visual states for selected slots */
.slot-btn { position: relative; overflow: hidden; }
.slot-btn.start {
    background: linear-gradient(90deg, #e6f0ff 0%, #dceeff 100%);
    color: #003a8c;
    border-color: #88b3ff;
    box-shadow: 0 6px 18px rgba(0,107,255,0.06);
}
.slot-btn.end {
    background: linear-gradient(90deg, #ffecec 0%, #ffdede 100%);
    color: #8b1d1d;
    border-color: #ff9b9b;
    box-shadow: 0 6px 18px rgba(255,77,77,0.06);
}
.slot-btn.in-range {
    background: linear-gradient(90deg, rgba(0,107,255,0.04) 0%, rgba(0,107,255,0.02) 100%);
    color: var(--primary-blue);
    border-color: rgba(0,107,255,0.08);
}

/* badges for start/end */
.slot-btn.start::after,
.slot-btn.end::after {
    content: attr(data-badge);
    position: absolute;
    right: 10px;
    top: 8px;
    background: rgba(255,255,255,0.9);
    color: rgba(0,0,0,0.8);
    font-size: 0.68rem;
    padding: 4px 8px;
    border-radius: 999px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.slot-btn.start::after { background: rgba(0,107,255,0.12); color: #0047b3; }
.slot-btn.end::after { background: rgba(255,77,77,0.12); color: #9b1f1f; }

/* larger emphasis for start and end */
.slot-btn.start, .slot-btn.end { font-weight: 800; }

/* ensure in-range has subtle left/right rounding when adjacent */
.slot-btn.in-range { border-radius: 6px; }

.confirm-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.confirm-action-btn:focus {
    outline: 3px solid rgba(0,107,255,0.14);
    outline-offset: 3px;
}

/* Lead flow styles */
.lead-flow { padding: 12px; border-radius: 10px; background: #fff; box-shadow: 0 6px 18px rgba(2,6,23,0.04); }
.lead-flow h4 { margin: 0 0 10px 0; }
.lead-flow { max-height: none; overflow: visible; }
.lead-review { color: var(--text-muted); margin-bottom: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lead-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* ensure actions in the two-column lead form span both columns and align right */
.lead-create-form .lead-actions { grid-column: 1 / -1; justify-content: flex-end; }
.lead-form label { display: block; margin-bottom: 10px; font-size: 0.9rem; color: var(--text-dark); }
.lead-form input,
.lead-form textarea { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #e2e8f0; box-sizing: border-box; }
.lead-success { padding: 12px; border-radius: 8px; background: #f0fff4; color: #065f46; font-weight: 600; }

/* Form layout helpers: two fields per row, collapse on small screens */
.field-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: stretch; }
.field { flex: 1 1 0; display: flex; flex-direction: column; }
.field .error-text { 
    color: #b91c1c;
    font-size: 0.85rem;
    /* margin-top: 6px;
    min-height: 18px;  */
}

@media (max-width: 650px) {
    .field-row { flex-direction: column; }
}

/* two-column grid for the lead create form so every row has two fields */
.lead-create-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lead-create-form .field { display: flex; flex-direction: column; }
.lead-create-form .field label { margin-bottom: 6px; }

/* Auth-like wrapper styles to mimic admin login layout */
.fsd-auth-wrapper {
    max-width: 450px;
    margin: 4.5rem auto;
    padding: 0 12px;
}

.fsd-auth-wrapper .company-logo { margin-bottom: 12px; }
.fsd-auth-wrapper .company-logo img, .fsd-auth-wrapper .company-logo svg { max-height: 96px; display:inline-block; }

.fsd-auth-wrapper .main-title { text-align: center; font-size: 1.25rem; margin: 6px 0 14px; color: #111827; }

/* Make the booking card appear like the small auth card */
.fsd-auth-wrapper .booking-card {
    display: block !important;
    max-width: 360px;
    margin: 0 auto;
    padding: 18px;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15,23,42,0.06);
    border: 1px solid rgba(0,0,0,0.06);
    background: #fff;
}

/* Hide the multi-column booking UI for the auth-card variant and show a compact confirm area */
.fsd-auth-wrapper .booking-card .sidebar,
.fsd-auth-wrapper .booking-card .calendar-container,
.fsd-auth-wrapper .booking-card .time-slots-container {
    display: none !important;
}

.fsd-auth-wrapper #confirmArea { display:block; }

/* Small-screen adjustments */
@media (max-width: 480px) {
    .fsd-auth-wrapper { margin-top: 3rem; }
    .fsd-auth-wrapper .company-logo img, .fsd-auth-wrapper .company-logo svg { max-height: 72px; }
}
.lead-create-form .hidden-field { padding: 0; border: none; background: transparent; }

@media (max-width: 650px) {
    .lead-create-form { grid-template-columns: 1fr; }
}

/* Utility: force round date tiles on all devices.
   Add `force-round` to `.fsd-booking-body` or `.fsd-auth-wrapper` to enable.
   Example: <div class="fsd-booking-body force-round"> or <body class="force-round"> */
.fsd-booking-body.force-round .day,
.fsd-auth-wrapper.force-round .day {
    aspect-ratio: 1/1 !important;
    padding: 0 !important;
    min-width: 34px !important;
    min-height: 34px !important;
    width: auto !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* When forcing round tiles on the auth-wrapper, reveal the multi-column
   booking UI so dates are visible. This only applies if you add
   `force-round` to `.fsd-auth-wrapper`. */
.fsd-auth-wrapper.force-round .booking-card {
    display: flex !important;
    max-width: 720px !important;
}
.fsd-auth-wrapper.force-round .booking-card .sidebar,
.fsd-auth-wrapper.force-round .booking-card .calendar-container,
.fsd-auth-wrapper.force-round .booking-card .time-slots-container {
    display: block !important;
}

/* ----------------------------
   Responsive tweaks for all devices
   - collapse columns on small viewports
   - keep only inner panes scrollable
   - tune paddings and font sizes
   ---------------------------- */

@media (max-width: 1200px) {
    .fsd-booking-body { padding: 18px 14px; }
    .booking-card { max-width: 920px; }
    .sidebar, .time-slots-container { padding: 20px; }
    #slotsList { max-height: calc(100vh - 340px); }
}

@media (max-width: 900px) {
    /* Stack columns vertically for tablets and small laptops */
    .booking-card { flex-direction: column; max-width: 760px; padding: 0; }
    .booking-card { align-items: stretch; }
    .sidebar, .calendar-container, .time-slots-container {
        width: 100%;
        padding: 14px;
        border-right: none;
        border-top: 1px solid var(--border-color);
    }
    .calendar-container { order: 1; }
    .time-slots-container { order: 2; }
    .sidebar { order: 3; }
    .calendar-grid { grid-auto-rows: minmax(40px, 1fr); }
    /* keep circular date tiles on smaller screens */
    .day { aspect-ratio: 1/1; padding: 0; min-width: 34px; min-height: 34px; border-radius: 50%; }
    #slotsList { max-height: calc(100vh - 420px); }
    .lead-create-form { grid-template-columns: 1fr; }
    .main-title { text-align: center; }
    .fsd-booking-body { overflow: auto; }
}

@media (max-width: 480px) {
    .fsd-booking-body { padding: 12px; }
    .booking-card { border-radius: 8px; }
    .slot-btn { padding: 10px 12px; font-size: 0.95rem; min-height: 44px; }
    .confirm-action-btn { min-width: 120px; padding: 10px 12px; font-size: 0.95rem; }
    .fsd-auth-wrapper { margin: 2rem 8px; max-width: 100%; }
    #slotsList { max-height: calc(100vh - 420px); }
    .main-title { font-size: 1.05rem; }
    .calendar-grid { gap: 4px; }
}

/* Very large screens: give more breathing room */
@media (min-width: 1600px) {
    .booking-card { max-width: 1200px; }
}

/* Utility: ensure inner scroll areas can shrink/grow correctly */
.booking-card, .booking-card * { box-sizing: border-box; }


/* full-width field (e.g. description) spans both columns */
.lead-create-form .full-width { grid-column: 1 / -1; }
.lead-create-form .full-width textarea { min-height: 120px; }

/* ensure lead container itself does not scroll internally */
#leadContainer { overflow: visible; }

@media (max-width: 650px) {
    .lead-review { grid-template-columns: 1fr; }
}

@media (max-width: 850px) {
    .confirm-wrapper { flex-direction: column; }
    .confirm-wrapper .slot-btn { width: 100%; }
    .confirm-action-btn { width: 100%; min-width: 0; flex: 1; }
}

/* Responsive */
@media (max-width: 850px) {
    .booking-card { flex-direction: column; }
    .sidebar, .calendar-container, .time-slots-container { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
}

/* Responsive improvements for medium and small screens */
@media (max-width: 1200px) {
    .sidebar { width: 28%; padding: 22px; }
    .calendar-container { width: 44%; padding: 22px; }
    .time-slots-container { width: 28%; padding: 22px; }
}

@media (max-width: 850px) {
    .booking-card { flex-direction: column; height: auto; min-height: 0; }
    .sidebar, .calendar-container, .time-slots-container { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
    .fsd-booking-body { padding: 20px 12px; }
    .calendar-container { padding: 18px; }
    .time-slots-container { padding: 18px; }
    #slotsList { max-height: 40vh; }
    .calendar-grid { gap: 6px; }
}

@media (max-width: 480px) {
    .main-title { font-size: 1.25rem; }
    .sidebar { padding: 12px; }
    .calendar-container { padding: 12px; }
    .time-slots-container { padding: 12px; }
    .profile img { width: 36px; }
    .logo-box { width: 22px; height: 22px; }
    .calendar-header { gap: 10px; }
    .grid-label { font-size: 0.6rem; }
    .day { font-size: 0.8rem; }
    .slot-btn { padding: 10px; font-size: 0.95rem; }
    #slotsList { max-height: 50vh; }
    .booking-card { box-shadow: none; border-radius: 8px; }
}
