/**
 * Doctors List Page Styles
 * Filter bar, page layout, and Material Design input components
 * @package    com_doctors
 * @since      1.0.0
 *
 * NOTE: CSS custom properties and elevation classes moved to design-tokens.css in v1.11.0
 */

/* ============================================
   Material Design Input Components
   ============================================ */

/* Outlined Text Input with Floating Label */
.md-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.md-input {
  width: 100%;
  height: var(--md-input-height);
  padding: var(--md-input-padding-y) var(--md-input-padding-x);
  border: var(--md-input-border-width) solid var(--md-border-color);
  border-radius: var(--md-input-border-radius);
  font-size: 16px;
  line-height: normal;
  font-family: inherit;
  color: var(--md-text-primary);
  background-color: transparent;
  transition: border-color var(--md-transition-duration-short) var(--md-transition-easing-standard);
  outline: none;
  box-sizing: border-box;
  margin: 0;
  min-height: var(--md-input-height);
  max-height: var(--md-input-height);
}

.md-input::placeholder {
  color: transparent;
}

.md-input:hover {
  border-color: var(--md-border-color-hover);
}

.md-input:focus {
  border-color: var(--md-primary);
  border-width: var(--md-input-focus-border-width);
  padding: calc(var(--md-input-padding-y) - 1px) calc(var(--md-input-padding-x) - 1px);
}

/* Input with icon prefix */
.md-input-with-icon {
  padding-left: 48px;
}

.md-input-with-icon:focus {
  padding-left: 47px;
}

/* Icon prefix positioning */
.md-icon-prefix {
  position: absolute;
  left: 12px;
  color: var(--md-text-secondary);
  pointer-events: none;
  z-index: 1;
}

.md-input-wrapper:focus-within .md-icon-prefix {
  color: var(--md-primary);
}

/* Floating Label */
.md-label {
  position: absolute;
  left: var(--md-input-padding-x);
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--md-text-secondary);
  background-color: var(--md-surface);
  padding: 0 4px;
  pointer-events: none;
  transition: all var(--md-transition-duration-standard) var(--md-transition-easing-standard);
  transform-origin: left center;
  z-index: 1;
}

/* Float label up when input has focus or value */
.md-input:focus ~ .md-label,
.md-input:not(:placeholder-shown) ~ .md-label,
.md-has-value .md-label {
  top: 0;
  transform: translateY(-55%) scale(0.75);
  color: var(--md-primary);
  font-size: 12px;
}

.md-input:not(:focus):not(:placeholder-shown) ~ .md-label,
.md-has-value:not(:focus-within) .md-label {
  color: var(--md-text-secondary);
}

/* Adjust label position for input with icon */
.md-input-with-icon ~ .md-label {
  left: 48px;
}

/* Icon Button (for clear button) */
.md-icon-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-text-secondary);
  border-radius: 50%;
  transition: background-color var(--md-transition-duration-short) var(--md-transition-easing-standard);
  z-index: 2;
}

.md-icon-btn:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.md-icon-btn:active {
  background-color: rgba(0, 0, 0, 0.12);
}

.md-clear-btn {
  display: none;
}

.md-clear-btn.visible {
  display: flex;
}

/* ============================================
   Material Design Select Components
   ============================================ */

/* Outlined Select Dropdown with Floating Label */
.md-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.md-select {
  width: 100%;
  height: var(--md-input-height);
  padding: var(--md-input-padding-y) 48px var(--md-input-padding-y) var(--md-input-padding-x);
  border: var(--md-input-border-width) solid var(--md-border-color);
  border-radius: var(--md-input-border-radius);
  font-size: 16px;
  font-family: inherit;
  color: var(--md-text-primary);
  background-color: transparent;
  transition: border-color var(--md-transition-duration-short) var(--md-transition-easing-standard);
  outline: none;
  appearance: none;
  cursor: pointer;
  box-sizing: border-box;
}

.md-select:hover {
  border-color: var(--md-border-color-hover);
}

.md-select:focus {
  border-color: var(--md-primary);
  border-width: var(--md-input-focus-border-width);
  padding: calc(var(--md-input-padding-y) - 1px) 47px calc(var(--md-input-padding-y) - 1px) calc(var(--md-input-padding-x) - 1px);
}

/* Empty option for floating label behavior */
.md-select option[value=""] {
  display: none;
}

/* Custom Dropdown Arrow */
.md-select-arrow {
  position: absolute;
  right: 12px;
  color: var(--md-text-secondary);
  pointer-events: none;
  transition: transform var(--md-transition-duration-short) var(--md-transition-easing-standard),
              color var(--md-transition-duration-short) var(--md-transition-easing-standard);
}

.md-select:focus ~ .md-select-arrow {
  color: var(--md-primary);
  transform: rotate(180deg);
}

/* Floating label for select (reuses .md-label). The empty option shows text ("All cities"),
   so a select's label always floats; it is primary-coloured only while the select has focus. */
.md-select-wrapper .md-select ~ .md-label,
.md-select-wrapper.md-has-value .md-label {
  top: 0;
  transform: translateY(-50%) scale(0.75);
  color: var(--md-primary);
  font-size: 16px;
}

.md-select-wrapper .md-select:not(:focus) ~ .md-label,
.md-select-wrapper.md-has-value:not(:focus-within) .md-label {
  color: var(--md-text-secondary);
}

/* ============================================
   Material Design Toggle Button Group
   ============================================ */

/* Toggle Group for Icon+Label Buttons */
.md-toggle-group-buttons {
  height: var(--md-input-height);
}

/* ============================================
   Material Design Button Components
   ============================================ */

/* Base Button Styles */
.md-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  min-height: 36px;
  border: none;
  border-radius: var(--md-input-border-radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.0892857143em;
  color: #fff;
  background-color: var(--md-primary);
  cursor: pointer;
  overflow: hidden;
  transition: background-color var(--md-transition-duration-short) var(--md-transition-easing-standard),
              box-shadow var(--md-transition-duration-short) var(--md-transition-easing-standard);
  box-shadow: var(--md-elevation-2);
  user-select: none;
  outline: none;
}

.md-btn:hover {
  background-color: var(--md-primary-dark);
  box-shadow: var(--md-elevation-4);
}

.md-btn:active {
  box-shadow: var(--md-elevation-3);
}

.md-btn:focus-visible {
  outline: 2px solid var(--md-primary-light);
  outline-offset: 2px;
}

/* Secondary Button Variant */
.md-btn-secondary {
  background-color: var(--md-secondary);
}

.md-btn-secondary:hover {
  background-color: #5a6268;
}

/* Button Label */
.md-btn-label {
  position: relative;
  z-index: 1;
}

/* Ripple Container */
.md-ripple {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

/* Ripple Wave Animation */
.md-ripple-wave {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  transform: scale(0);
  pointer-events: none;
  animation: md-ripple-animation 600ms cubic-bezier(0.0, 0.0, 0.2, 1);
}

@keyframes md-ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Disabled Button State */
.md-btn:disabled {
  background-color: rgba(0, 0, 0, 0.12);
  color: var(--md-text-disabled);
  cursor: not-allowed;
  box-shadow: none;
}

.md-btn:disabled:hover {
  background-color: rgba(0, 0, 0, 0.12);
  box-shadow: none;
}

/* Base styles */
.doctors-list-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 10px;
}

.doctors-count {
    font-size: 1.1em;
    color: #666;
    white-space: nowrap;
}

/* Responsive flexbox for doctors container */
.doctors-container {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
}

/* Card sizing in container */
.doctors-container .doctor-card-link {
    flex: 0 0 calc(33.333% - 16px);
    max-width: calc(33.333% - 16px);
}

/* Card styles are in doctor-card.css */

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-info {
    color: #31708f;
    background-color: #d9edf7;
    border-color: #bce8f1;
}

/* ============================================
   Soft UI Filter Bar (iOS-style Redesign)
   ============================================ */

/* Filter Bar Container - Grey Surface with Soft UI */
.doctors-filter-bar {
    background: var(--md-doctor-photo-bg, #e5e7eb);
    border-radius: var(--filter-panel-radius);
    padding: 12px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    color: var(--md-text-dark);
}

/* Filter Row - CSS Grid Layout */
.filter-row {
    display: grid;
    gap: 12px;
    align-items: center;
}

/* Primary Filter Row: Search | Sort | Actions */
.filter-row-primary {
    grid-template-columns: 1fr auto auto;
}

/* Secondary Filter Row (Toggleable) */
.filter-row-secondary {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.06);
    grid-template-columns: 1fr;
}

/* ============================================
   Soft UI Inputs (White "Pills" on Grey BG)
   ============================================ */

/* Override default input wrapper for soft UI */
.doctors-filter-bar .md-input-wrapper,
.doctors-filter-bar .md-select-wrapper {
    background: var(--md-surface);
    border-radius: var(--filter-input-radius);
    box-shadow: var(--md-shadow-sm);
    height: var(--filter-input-height);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.doctors-filter-bar .md-input-wrapper:focus-within,
.doctors-filter-bar .md-select-wrapper:focus-within {
    box-shadow: 0 0 0 2px var(--md-primary), 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
    z-index: 2;
}

/* Soft UI Input Fields */
.doctors-filter-bar .md-input,
.doctors-filter-bar .md-select {
    height: 100%;
    border: none;
    background: transparent;
    border-radius: var(--filter-input-radius);
    padding: 16px 20px;
    font-size: 1rem;
    color: var(--md-text-dark);
    outline: none;
}

.doctors-filter-bar .md-input:focus,
.doctors-filter-bar .md-select:focus {
    border: none;
    padding: 16px 20px;
}

.doctors-filter-bar .md-input-with-icon {
    padding-left: 48px;
}

.doctors-filter-bar .md-input-with-icon:focus {
    padding-left: 48px;
}

/* Soft UI Floating Labels */
.doctors-filter-bar .md-label {
    left: 20px;
    top: 14px;
    transform: none;
    color: var(--md-text-grey);
    font-size: 1rem;
    background: transparent;
}

/* Floating Label Animation State */
.doctors-filter-bar .md-input:focus ~ .md-label,
.doctors-filter-bar .md-input:not(:placeholder-shown) ~ .md-label,
.doctors-filter-bar .md-select:focus ~ .md-label,
.doctors-filter-bar .md-has-value .md-label {
    /* top: 2px;
    transform: none; */
    font-size: 16px;
    color: var(--md-primary);
    font-weight: 600;
}

/* Adjust label position for search icon */
.doctors-filter-bar .md-input-with-icon ~ .md-label {
    left: 48px;
}

/* Icon Prefix in Soft UI */
.doctors-filter-bar .md-icon-prefix {
    left: 14px;
    color: var(--md-text-grey);
    font-size: 22px;
}

.doctors-filter-bar .md-input-wrapper:focus-within .md-icon-prefix {
    color: var(--md-primary);
}

/* Clear Button */
.doctors-filter-bar .md-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--md-text-grey);
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.doctors-filter-bar .md-clear-btn.visible {
    display: flex;
}

.doctors-filter-bar .md-clear-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--md-text-dark);
}

/* Select Arrow */
.doctors-filter-bar .md-select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-text-grey);
    pointer-events: none;
    transition: transform 0.2s;
}

.doctors-filter-bar .md-select:focus ~ .md-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Filter Group Base */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    justify-content: center;
}

/* Filter Actions Container */
.filter-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: auto;
}

/* ============================================
   Minimalist Sorting UI
   ============================================ */

.filter-sort-minimal {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--md-surface);
    padding: 4px 12px 4px 16px;
    border-radius: var(--filter-input-radius);
    height: var(--filter-input-height);
    box-shadow: var(--md-shadow-sm);
    width: fit-content;
    flex-direction: row;
}

.sort-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--md-text-grey);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.sort-actions {
    display: flex;
    gap: 4px;
}

.sort-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    color: var(--md-text-grey);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--md-primary);
}

.sort-btn.active {
    color: var(--md-primary);
    background: var(--md-primary-alpha);
}

/* ============================================
   Soft UI Buttons (Filter Toggle & Reset)
   ============================================ */

/* Soft button group (no borders) */
.doctors-filter-bar .md-toggle-group-buttons {
    display: inline-flex;
    border-radius: var(--filter-input-radius, 24px);
    overflow: hidden;
    box-shadow: var(--md-shadow-sm);
    background: transparent;
}

/* ============================================
   Chip-Style Patient Type Toggle Buttons
   ============================================ */

/* Patient Type Filter Container */
.filter-patients {
    flex-direction: row;
    width: auto;
    align-items: center;
}

/* MUI-style ButtonGroup (Patient Type Filter) */
.md-button-group {
    display: inline-flex;
    border-radius: var(--filter-input-radius, 24px);
    overflow: hidden;
    box-shadow: var(--md-shadow-sm);
}

.md-button-group-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--md-surface);
    border: none;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding: 12px 20px;
    font-size: 0.9rem;
    color: var(--md-text-sub);
    cursor: pointer;
    transition: all 0.15s var(--md-transition-easing-standard);
    font-weight: 500;
    white-space: nowrap;
}

.md-button-group-btn:last-child {
    border-right: none;
}

.md-button-group-btn:hover {
    background: var(--md-primary-alpha);
}

/* overflow: hidden on the group would clip the default focus outline */
.md-button-group-btn:focus-visible,
.sort-btn:focus-visible {
    outline: 2px solid var(--md-primary);
    outline-offset: -2px;
}

/* FE#6: show that the secondary filter row is open */
#filter-toggle[aria-expanded="true"] {
    background: var(--md-primary-alpha);
    color: var(--md-primary);
}

.md-button-group-btn.active {
    background: var(--md-primary);
    color: white;
}

.md-btn-text {
    white-space: nowrap;
}

/* ============================================
   Result count and sorting bar
   ============================================ */

.doctors-count-sorting-bar {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    padding: 12px 0px 12px 0px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.doctors-count-container {
    flex: 2 1;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Mobile (<576px): Compact layout */
@media screen and (max-width: 575px) {
    /* Primary row becomes 2 rows */
    .filter-row-primary {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
    }

    /* Search takes full width top row */
    .filter-search {
        grid-column: 1 / -1;
    }

    /* Sort and buttons share second row */
    .filter-sort-minimal {
        width: auto;
        /* flex: 1; */
        justify-content: space-between;
        flex-direction: row; 
    }

    /* Icon only on mobile */
    .md-btn-label {
        display: none;
    }

    /* ButtonGroup compact on mobile; keep 44px touch targets */
    .md-button-group-btn {
        padding: 8px 12px;
        min-height: 44px;
        font-size: 0.85rem;
    }
}

/* Tablet (768px+): 2-column grid for secondary row */
@media screen and (min-width: 768px) {
    .filter-row-secondary {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Desktop (992px+): 3-column grid for secondary row */
@media screen and (min-width: 992px) {
    .filter-row-secondary {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .filter-city,
    .filter-spec,
    .filter-patients {
        grid-column: auto;
    }
}

/* No Results Message */
.doctors-no-results {
    margin-bottom: 30px;
}

.doctors-no-results .alert {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px;
    text-align: center;
}

.doctors-no-results p {
    margin: 0;
    font-size: 1.1em;
}

/* Large desktop (1200px+): 3 cards per row */
@media screen and (min-width: 1200px) {
    .doctors-container .doctor-card-link {
        flex: 0 0 calc(33.333% - 16px);
        max-width: calc(33.333% - 16px);
    }
}

/* Desktop (992px - 1199px): 3 cards per row */
@media screen and (min-width: 992px) and (max-width: 1199px) {
    .doctors-container .doctor-card-link {
        flex: 0 0 calc(33.333% - 16px);
        max-width: calc(33.333% - 16px);
    }
}

/* Tablet (768px - 991px): 2 cards per row */
@media screen and (min-width: 768px) and (max-width: 991px) {
    .doctors-list-page {
        padding: 16px;
    }

    .page-header {
        margin-bottom: 30px;
    }

    .page-header h1 {
        font-size: 2em;
    }

    .doctors-container {
        gap: 20px;
    }

    .doctors-container .doctor-card-link {
        flex: 0 0 calc(50% - 10px);
        max-width: calc(50% - 10px);
    }
}

/* Large mobile (576px - 767px): 2 cards per row */
@media screen and (min-width: 576px) and (max-width: 767px) {
    .doctors-list-page {
        padding: 12px;
    }

    .page-header {
        margin-bottom: 24px;
    }

    .page-header h1 {
        font-size: 1.75em;
    }

    .doctors-count {
        font-size: 1em;
    }

    .doctors-container {
        gap: 16px;
    }

    .doctors-container .doctor-card-link {
        flex: 0 0 calc(50% - 8px);
        max-width: calc(50% - 8px);
    }
}

/* Small mobile (up to 575px): 1 card per row */
@media screen and (max-width: 575px) {
    .doctors-list-page {
        padding: 10px;
    }

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

    .page-header h1 {
        font-size: 1.5em;
    }

    .doctors-count {
        font-size: 0.95em;
    }

    .doctors-container {
        gap: 16px;
    }

    .doctors-container .doctor-card-link {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Disable hover transform on touch devices */
    .doctor-card-link:hover {
        transform: none;
    }

    /* Add active state for touch feedback */
    .doctor-card-link:active {
        transform: scale(0.98);
    }

    .doctors-no-results .alert {
        padding: 20px;
    }
}

/* Improve touch targets */
@media (hover: none) and (pointer: coarse) {
    .doctor-card-link {
        -webkit-tap-highlight-color: transparent;
    }

    .doctor-card-link:hover {
        transform: none;
    }

    .doctor-card-link:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}
