/* Appointment Form Styles */
:root {
    --color-brand-bg: #EEF8FF;
}

.appointment-form-container {
    background-color: var(--color-gray-50);
    min-height: 400px;
}

.text-primary {
    color: var(--primary-color);
}

/* Custom date input styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    color: transparent;
    opacity: 1;
    display: block;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="15" viewBox="0 0 24 24"><path fill="%236B7280" d="M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"/></svg>') no-repeat;
    width: 20px;
    height: 20px;
    background-position: center;
    cursor: pointer;
}

/* Custom select arrow handled via SVG span in markup */
select.appearance-none {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: none;
    padding-right: 2.5rem;
}

/* Select2 custom styles to match Tailwind classes on native <select> */
.select2-container--default .select2-selection--single {
    background-color: #f9fafb;
    border: 1px solid #9ca3af;
    border-radius: 0.5rem;
    height: auto;
    padding: 0.75rem 1rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 1.2;
    padding: 0;
    color: #374151;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    display: none;
}

.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
    outline: none;
}

.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #f9fafb;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Style for required select inputs */
select:required:invalid {
    color: var(--color-gray-400);
}

option[value=""][disabled] {
    display: none;
}

/* Radio button enhancements */
input[type="radio"] {
    accent-color: var(--primary-color);
}

input[type="radio"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Checkbox enhancements */
input[type="checkbox"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Form field focus states */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

/* Button hover effects */
button:not(:disabled):active {
    transform: translateY(0);
}

/* Loading spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .appointment-form-container {
        padding: 1rem;
    }

    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* Smooth transitions */
* {
    transition: border-color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.appointment-form-container::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.appointment-form-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Custom styles for file upload areas */
.upload-area {
    border: 2px dashed var(--color-gray-200);
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: var(--color-gray-background);
}

.upload-area.has-file {
    border-color: var(--primary-color);
    background-color: var(--color-blue-50);
}

/* File upload container styles */
.file-upload-container {
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

.file-upload-container .upload-placeholder,
.file-upload-container .upload-preview {
    transition: opacity 0.3s ease;
}

.file-upload-container .upload-preview img {
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-upload-container .remove-file-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--color-red-100);
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.file-upload-container .remove-file-btn:hover {
    background-color: var(--color-red-200);
    transform: translateY(-1px);
}

.file-upload-container .preview-filename {
    word-break: break-all;
    color: var(--color-gray-500);
    margin-top: 0.5rem;
}

/* Multiple attachments upload area */
.attachments-upload-area {
    min-height: 150px;
    position: relative;
    transition: all 0.3s ease;
}

.attachments-upload-area.dragging {
    border-color: var(--primary-color);
    background-color: var(--color-blue-50);
    transform: scale(1.02);
}

#attachments-preview-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Scrollbar styling for attachments preview */
#attachments-preview-container::-webkit-scrollbar {
    width: 6px;
}

#attachments-preview-container::-webkit-scrollbar-track {
    background: var(--color-gray-100);
    border-radius: 3px;
}

#attachments-preview-container::-webkit-scrollbar-thumb {
    background: var(--color-gray-400);
    border-radius: 3px;
}

#attachments-preview-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-600);
}

/* Loading state for file upload */
.file-upload-container.uploading,
.attachments-upload-area.uploading {
    pointer-events: none;
    opacity: 0.6;
}

.file-upload-container.uploading::after,
.attachments-upload-area.uploading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

/* Status badges (if needed in form) */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Custom year dropdown injected into the flatpickr calendar header.
   Replaces the native <select> (whose OS popup overflows the screen for a
   long year range) with a contained, scrollable panel. */
.flatpickr-year-dropdown {
    position: relative;
    display: inline-block;
    margin-left: 0.5ch;
    vertical-align: middle;
}

.flatpickr-year-dropdown__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: none;
    font: inherit;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: inherit;
}

.flatpickr-year-dropdown__toggle::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.7;
}

.flatpickr-year-dropdown__panel {
    position: absolute;
    z-index: 20;
    display: none;
    min-width: 88px;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    padding: 0.25rem 0;
    text-align: left;
}

.flatpickr-year-dropdown__panel.is-open {
    display: block;
}

.flatpickr-year-dropdown__option {
    padding: 0.4rem 0.85rem;
    font-size: 0.95rem;
    line-height: 1.2;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.flatpickr-year-dropdown__option:hover {
    background: var(--color-brand-bg, #EEF8FF);
}

.flatpickr-year-dropdown__option.is-selected {
    background: var(--primary-color, #023C69);
    color: #fff;
    font-weight: 600;
}

.flatpickr-year-dropdown__panel::-webkit-scrollbar {
    width: 8px;
}

.flatpickr-year-dropdown__panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.flatpickr-year-dropdown__panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* The custom year-dropdown toggle carries the caret; the month toggle reuses
   the same classes, so both month and year render identically. */
.flatpickr-year-dropdown__toggle {
    white-space: nowrap;
}

/* Selected day uses the brand primary color (overrides flatpickr's blue). */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.startRange,
.flatpickr-day.selected.endRange {
    background: var(--primary-color, #023C69);
    border-color: var(--primary-color, #023C69);
    color: #fff;
}

/* Keyboard/hover focus on a day picks up the primary tint too. */
.flatpickr-day:hover,
.flatpickr-day:focus {
    border-color: var(--primary-color, #023C69);
}

/* Print styles */
@media print {
    .appointment-form-container {
        background-color: white;
    }

    button {
        display: none;
    }
}
