/* =================================================================
   EHR Calendar and Time Picker Styles
   ================================================================= */

/* Date picker container */
.appointment-popup-date-wrapper {
    position: relative;
    display: inline-block;
}

/* Add a calendar icon to the date input */
.appointment-popup-date-wrapper::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    opacity: 0.6;
    /* Inline SVG calendar icon */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'/><line x1='16' y1='2' x2='16' y2='6'/><line x1='8' y1='2' x2='8' y2='6'/><line x1='3' y1='10' x2='21' y2='10'/></svg>");
}

/* Make room for the calendar icon */
.appointment-popup-date-wrapper .appointment-popup-date-input {
    padding-right: 28px;
}

/* Date input field styling */
input.appointment-popup-date-input {
    padding: 5px 10px;
    font-size: 13px;
    width: 140px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    outline: none;
    transition: all 0.15s ease;
    height: 26px;
}

.appointment-popup-date-input:hover {
    border-color: #007BFF;
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.1);
}

.appointment-popup-date-input:focus {
    border-color: #007BFF;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

/* Custom calendar dropdown - positioning handled by JavaScript */
.appointment-popup-date-menu {
    background: white;
    border: 3px solid #007BFF;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 16px 48px rgba(0, 123, 255, 0.2), 0 8px 20px rgba(0, 0, 0, 0.12);
    display: none;
    font-size: 12px;
    overflow: visible;
    z-index: 20000;
    /* Positioning handled by JavaScript */
}


.appointment-popup-date-menu.show {
    display: block;
    animation: appointmentCalendarFadeIn 0.15s ease-out;
}

@keyframes appointmentCalendarFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Calendar header - compact original size */
.appointment-popup-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.appointment-popup-calendar-nav {
    background: none;
    border: none;
    font-size: 16px;
    color: #007BFF;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-weight: 600;
}

.appointment-popup-calendar-nav:hover {
    background: rgba(0, 123, 255, 0.1);
    color: #0056b3;
}

/* Enhanced Month/Year selectors - compact but improved */
.appointment-popup-calendar-selectors {
    display: flex;
    align-items: center;
    gap: 6px;
}

.appointment-popup-month-select,
.appointment-popup-year-select {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 10px;
    padding-right: 20px;
    min-width: 70px;
    max-height: 28px;
}

.appointment-popup-month-select {
    min-width: 100px;
    max-width: 110px;
}

.appointment-popup-year-select {
    min-width: 70px;
    max-width: 80px;
}

.appointment-popup-month-select:hover,
.appointment-popup-year-select:hover {
    border-color: #007BFF;
    background-color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.appointment-popup-month-select:focus,
.appointment-popup-year-select:focus {
    outline: none;
    border-color: #007BFF;
    background-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

/* Enhanced dropdown options */
.appointment-popup-month-select option,
.appointment-popup-year-select option {
    padding: 8px 12px;
    font-weight: 500;
    color: #374151;
    background: white;
}

/* Reduce the height of year dropdown menu options */
.appointment-popup-year-select option {
    padding: 3px 6px;
    line-height: 1.1;
    height: 18px;
    font-size: 0.85em;
}

/* Custom year dropdown styling */
.appointment-popup-year-dropdown {
    position: relative;
    display: inline-block;
}

.appointment-popup-year-button {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
    max-width: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.appointment-popup-year-button:hover {
    border-color: #007BFF;
    background-color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.appointment-popup-year-button .dropdown-arrow {
    font-size: 8px;
    color: #666;
    transition: transform 0.2s ease;
}

.appointment-popup-year-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 80px;
    max-height: 240px;
    background: white;
    border: 1px solid #007BFF;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    overflow-y: auto;
    z-index: 1000;
    font-size: 12px;
}

.appointment-popup-year-menu .year-option {
    padding: 4px 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-size: 11px;
    line-height: 1.2;
}

.appointment-popup-year-menu .year-option:hover {
    background-color: #f3f4f6;
    color: #007BFF;
}

.appointment-popup-year-menu .year-option.selected {
    background-color: #007BFF;
    color: white;
    font-weight: 600;
}

/* Custom scrollbar for year menu */
.appointment-popup-year-menu::-webkit-scrollbar {
    width: 6px;
}

.appointment-popup-year-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.appointment-popup-year-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.appointment-popup-year-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.appointment-popup-month-select option:hover,
.appointment-popup-year-select option:hover {
    background: #f3f4f6;
    color: #007BFF;
}

.appointment-popup-month-select option:checked,
.appointment-popup-year-select option:checked {
    background: #007BFF;
    color: white;
    font-weight: 600;
}

.appointment-popup-calendar-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

/* Calendar grid */
.appointment-popup-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

/* Day headers */
.appointment-popup-calendar-day-header {
    background: #f8fafc;
    padding: 6px 4px;
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    border: 1px solid #e2e8f0;
}

/* Calendar day cells */
.appointment-popup-calendar-day {
    background: white;
    padding: 6px 4px;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid #e2e8f0;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.appointment-popup-calendar-day:hover {
    background: #007BFF;
    color: white;
    transform: scale(1.05);
}

.appointment-popup-calendar-day.other-month {
    color: #cbd5e1;
    background: #f8fafc;
}

.appointment-popup-calendar-day.other-month:hover {
    background: #e2e8f0;
    color: #64748b;
    transform: none;
}

.appointment-popup-calendar-day.today {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}

.appointment-popup-calendar-day.selected {
    background: #0056b3;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.4);
}

.appointment-popup-calendar-day.disabled {
    background: #f8f9fa;
    color: #dee2e6;
    cursor: not-allowed;
    pointer-events: none;
}

.appointment-popup-calendar-day.disabled:hover {
    background: #f8f9fa;
    color: #dee2e6;
    transform: none;
    cursor: not-allowed;
}

/* =================================================================
   Time Picker Styles
   ================================================================= */

/* Time picker container */
.appointment-popup-time-wrapper {
    position: relative;
    display: inline-block;
}

/* Add a clock icon to the time input */
.appointment-popup-time-wrapper::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    opacity: 0.6;
    /* Inline SVG clock icon */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><polyline points='12 6 12 12 16 14'/></svg>");
}

/* Make room for the clock icon */
.appointment-popup-time-wrapper .appointment-popup-time-input {
    padding-right: 28px;
}

/* Time input field - enhanced styling */
input.appointment-popup-time-input {
    padding: 5px 10px;
    font-size: 13px;
    width: 100px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    outline: none;
    transition: all 0.15s ease;
    height: 26px;
}

.appointment-popup-time-input:hover {
    border-color: #007BFF;
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.1);
}

.appointment-popup-time-input:focus {
    border-color: #007BFF;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

/* Premium time picker dropdown - positioning handled by JavaScript */
.appointment-popup-time-menu {
    background: white;
    border: 3px solid #007BFF;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 16px 48px rgba(0, 123, 255, 0.2), 0 8px 20px rgba(0, 0, 0, 0.12);
    display: none;
    font-size: 10px;
    overflow: visible;
    z-index: 2000;
    /* Positioning handled by JavaScript */
}


/* Mobile overlay for time picker */
.appointment-popup-time-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 19999;
    display: none;
}

.appointment-popup-time-overlay.show {
    display: block;
}

.appointment-popup-time-menu.show {
    display: block;
    animation: appointmentTimePickerFadeIn 0.15s ease-out;
}

@keyframes appointmentTimePickerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Perfect table grid layout */
.appointment-popup-time-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    width: 100%;
    background: white;
    border-collapse: collapse;
}

/* Time columns - perfect table cells with connected borders */
.appointment-popup-time-grid .time-column {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    border-right: 1px solid #d0d0d0;
    min-width: 75px;
    background: white;
    position: relative;
}

.appointment-popup-time-grid .time-column:last-child {
    border-right: none;
}

/* Hour groups - table rows with seamless borders */
.appointment-popup-time-grid .hour-group {
    position: relative;
    margin: 0;
    padding: 4px 6px;
    border-bottom: 1px solid #d0d0d0;
    transition: background-color 0.15s ease;
    background: white;
}

.appointment-popup-time-grid .hour-group:last-child,
.appointment-popup-time-grid .hour-group.hour-group-last {
    border-bottom: none;
}

/* Enhanced hover effect for hour groups */
.appointment-popup-time-grid .hour-group:hover {
    background-color: rgba(0, 123, 255, 0.04);
}

/* Time option styling - enhanced hierarchy */
.appointment-popup-time-grid .time-option {
    padding: 2px 4px;
    cursor: pointer;
    color: #444;
    white-space: nowrap;
    border-radius: 3px;
    background: transparent;
    font-size: 10.5px;
    line-height: 1.4;
    transition: all 0.12s ease;
    margin: 1px 0;
}

/* Hour labels (h4 elements) - premium styling */
.appointment-popup-time-grid .hour-group h4.time-option {
    font-weight: 700;
    font-size: 11px;
    color: #0056b3;
    margin-bottom: 2px;
    padding: 3px 4px;
    background: rgba(0, 123, 255, 0.06);
    border-radius: 3px;
}

/* Minute options - subtle indented styling */
.appointment-popup-time-grid .hour-group .time-option:not(h4) {
    font-size: 10px;
    opacity: 0.92;
    margin-left: 8px;
    color: #555;
}

/* Enhanced hover and active states */
.appointment-popup-time-grid .time-option:hover {
    background: #007BFF;
    color: white;
    transform: scale(1.03);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.appointment-popup-time-grid .time-option.active {
    background: #0056b3;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 86, 179, 0.4);
}

/* Time group container */
.appointment-popup-time-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.appointment-popup-time-group span {
    font-weight: 500;
    color: #666;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .appointment-popup-time-menu {
        min-width: 300px;
        max-width: 340px;
        border-width: 2px;
        font-size: 10px;
    }

    .appointment-popup-time-grid .time-column {
        min-width: 70px;
        padding: 0;
    }

    .appointment-popup-time-grid .hour-group {
        padding: 3px 4px;
    }

    .appointment-popup-time-grid .time-option {
        font-size: 9.5px;
        padding: 1px 3px;
    }

    .appointment-popup-time-grid .hour-group h4.time-option {
        font-size: 10px;
        padding: 2px 3px;
    }

    .appointment-popup-time-input {
        width: 70px;
        font-size: 12px;
    }

    .appointment-popup-date-menu {
        width: 300px;
    }

}

@media (max-width: 480px) {
    .appointment-popup-time-menu {
        min-width: 280px;
        max-width: 300px;
        border-width: 2px;
        font-size: 9px;
    }

    .appointment-popup-time-grid .time-column {
        min-width: 65px;
    }

    .appointment-popup-time-grid .hour-group {
        padding: 2px 3px;
    }

    .appointment-popup-time-grid .time-option {
        font-size: 9px;
        padding: 1px 2px;
    }

    .appointment-popup-time-grid .hour-group h4.time-option {
        font-size: 9.5px;
        padding: 2px 2px;
    }

    .appointment-popup-time-input {
        width: 65px;
        font-size: 11px;
    }

    .appointment-popup-date-menu {
        width: 280px;
    }
}

/* Dark Mode Overrides for EHR Calendar & Time Pickers */
[data-bs-theme="dark"] .appointment-popup-date-menu,
[data-bs-theme="dark"] .appointment-popup-time-menu,
html.dark-mode .appointment-popup-date-menu,
html.dark-mode .appointment-popup-time-menu {
    background-color: #1e1e24 !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6) !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-header,
html.dark-mode .appointment-popup-calendar-header {
    background-color: #26262e !important;
    border-bottom-color: #3f4756 !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-title,
html.dark-mode .appointment-popup-calendar-title {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .appointment-popup-month-select,
[data-bs-theme="dark"] .appointment-popup-year-select,
[data-bs-theme="dark"] .appointment-popup-year-button,
html.dark-mode .appointment-popup-month-select,
html.dark-mode .appointment-popup-year-select,
html.dark-mode .appointment-popup-year-button {
    background-color: #26262e !important;
    border-color: #3f4756 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .appointment-popup-year-menu,
html.dark-mode .appointment-popup-year-menu {
    background-color: #1e1e24 !important;
    border-color: #3b82f6 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .appointment-popup-year-menu .year-option,
html.dark-mode .appointment-popup-year-menu .year-option {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .appointment-popup-year-menu .year-option:hover,
html.dark-mode .appointment-popup-year-menu .year-option:hover {
    background-color: #2d3748 !important;
    color: #60a5fa !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-grid,
html.dark-mode .appointment-popup-calendar-grid {
    background-color: #2d3748 !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-day-header,
html.dark-mode .appointment-popup-calendar-day-header {
    background-color: #26262e !important;
    color: #94a3b8 !important;
    border-color: #3f4756 !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-day,
html.dark-mode .appointment-popup-calendar-day {
    background-color: #1e1e24 !important;
    color: #f1f5f9 !important;
    border-color: #2d3748 !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-day:hover,
html.dark-mode .appointment-popup-calendar-day:hover {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-day.other-month,
html.dark-mode .appointment-popup-calendar-day.other-month {
    background-color: #17171d !important;
    color: #64748b !important;
}

[data-bs-theme="dark"] .appointment-popup-calendar-day.selected,
html.dark-mode .appointment-popup-calendar-day.selected {
    background-color: #2563eb !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .time-column,
html.dark-mode .appointment-popup-time-grid .time-column {
    background-color: #1e1e24 !important;
    border-right-color: #2d3748 !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .hour-group,
html.dark-mode .appointment-popup-time-grid .hour-group {
    background-color: #1e1e24 !important;
    border-bottom-color: #2d3748 !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .hour-group:hover,
html.dark-mode .appointment-popup-time-grid .hour-group:hover {
    background-color: #26262e !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .time-option,
html.dark-mode .appointment-popup-time-grid .time-option {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .hour-group h4.time-option,
html.dark-mode .appointment-popup-time-grid .hour-group h4.time-option {
    color: #60a5fa !important;
    background-color: rgba(59, 130, 246, 0.15) !important;
}

[data-bs-theme="dark"] .appointment-popup-time-grid .time-option:hover,
html.dark-mode .appointment-popup-time-grid .time-option:hover {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}