/**
 * Frontend Styles
 * Appointment Scheduler Plugin
 */

/* Main Container */
.appointment-scheduler-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.appointment-scheduler-header {
    text-align: center;
    margin-bottom: 30px;
}

.appointment-scheduler-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.appointment-scheduler-header p {
    color: #666;
    font-size: 16px;
}

/* Legend */
.appointment-scheduler-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.legend-color.available {
    background-color: #92b4bd;
}

.legend-color.selected {
    background-color: #b51782;
}

.legend-color.booked {
    background-color: #9E9E9E;
}

.legend-color.blocked {
    background-color: #ed694e;
}

/* Calendar */
.appointment-calendar {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Month navigation */
.calendar-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f8f8;
    border-radius: 8px;
    border: 1px solid #eee;
}

.calendar-nav-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    flex: 1;
    text-align: center;
    letter-spacing: 0.02em;
}

.month-nav-btn {
    background: transparent;
    color: #92b4bd;
    border: 2px solid #92b4bd;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.month-nav-btn:hover:not(:disabled) {
    background: #92b4bd;
    color: white;
}

.month-nav-btn:disabled {
    border-color: #ddd;
    color: #ddd;
    cursor: default;
}

/* Month grid */
.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-header {
    text-align: center;
    padding: 8px 4px;
    font-weight: 600;
    font-size: 12px;
    color: #555;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 2px;
}

.cal-day {
    min-height: 80px;
    padding: 5px;
    border: 1px solid #eee;
    border-radius: 4px;
    background: #fff;
    vertical-align: top;
}

.cal-day-empty {
    background: #fafafa;
    border-color: #f5f5f5;
    min-height: 80px;
}

.cal-day-past {
    background: #f8f8f8;
    opacity: 0.55;
}

.cal-day-number {
    font-size: 12px;
    font-weight: 700;
    color: #444;
    margin-bottom: 4px;
}

.cal-day-month {
    font-size: 10px;
    font-weight: 400;
    color: #999;
}

.cal-slots {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.slot-button {
    display: block;
    width: 100%;
    height: 28px;
    padding: 0 4px;
    background: #92b4bd;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 28px;
    text-align: center;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.slot-button:hover {
    background: #7a9da7;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(146, 180, 189, 0.4);
}

.slot-button:active {
    transform: translateY(0);
}

/* Selected slot */
.time-slot.selected .slot-button {
    background: #b51782;
    box-shadow: 0 0 0 3px rgba(181, 23, 130, 0.35);
}

.time-slot.selected .slot-button:hover {
    background: #8e1163;
}

.time-slot.booked .slot-unavailable,
.time-slot.blocked .slot-unavailable,
.time-slot.past .slot-unavailable {
    display: block;
    width: 100%;
    height: 28px;
    padding: 0 4px;
    background: #9E9E9E;
    color: white;
    border-radius: 5px;
    text-align: center;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 28px;
    box-sizing: border-box;
    cursor: not-allowed;
}

.time-slot.blocked .slot-unavailable {
    background: #ed694e;
}

.time-slot.past .slot-unavailable {
    background: #E0E0E0;
    color: #999;
}

.no-slots-message {
    text-align: center;
    color: #999;
    font-style: italic;
    margin: 10px 0;
}

/* Modal */
.appointment-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #fefefe;
    margin: 3% auto;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #000;
}

.modal-content h3 {
    margin-top: 0;
    color: #333;
    margin-bottom: 15px;
    font-size: 20px;
}

.modal-appointment-info {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}

.modal-appointment-info p {
    margin: 5px 0;
    color: #333;
}

/* Form Styles */
.form-group {
    margin-bottom: 6px;
}

.form-group-inline {
    display: flex;
    gap: 8px;
}

.form-group-inline .input-postal {
    flex: 0 0 120px;
}

.form-group-inline .input-city {
    flex: 1;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
    margin-bottom: 0px !important;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #297233;
}

.form-info-text {
    background: #e3f2fd;
    padding: 12px;
    border-radius: 5px;
    margin: 15px 0 12px 0;
    border-left: 4px solid #2196F3;
}

.form-info-text p {
    margin: 0;
    color: #1976D2;
    font-size: 13px;
    line-height: 1.4;
}

.form-privacy-text {
    background: #f5f5f5;
    padding: 8px;
    border-radius: 5px;
    margin-top: 12px;
    text-align: center;
}

.form-privacy-text p {
    margin: 0;
    color: #666;
    font-size: 12px;
    font-style: italic;
}

.form-message {
    margin: 15px 0;
    padding: 10px;
    border-radius: 5px;
    display: none;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.form-actions .button {
    flex: 1;
}

.button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.button-primary {
    background: #92b4bd;
    color: white;
}

.button-primary:hover {
    background: #7a9da7;
}

.button-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.button-secondary:hover {
    background: #e0e0e0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .appointment-scheduler-wrapper {
        padding: 10px;
    }

    .appointment-calendar {
        padding: 12px 10px;
    }

    .calendar-nav-header {
        padding: 10px 12px;
        margin-bottom: 14px;
    }

    .calendar-nav-header h3 {
        font-size: 16px;
    }

    .appointment-scheduler-legend {
        gap: 12px;
        margin-bottom: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px 16px;
    }

    .form-group-inline {
        flex-direction: column;
        gap: 0;
    }

    .form-group-inline .input-postal {
        flex: unset;
    }

    .selection-panel-inner {
        padding: 12px 14px;
        gap: 10px;
    }

    .selection-count {
        font-size: 14px;
    }

    .selection-list {
        font-size: 12px;
    }
}

/* Phones — horizontal-scrollable calendar grid */
@media (max-width: 600px) {
    /* Allow calendar to scroll sideways so day cells stay usable */
    .calendar-month {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px;
        padding: 0 10px;
    }

    .calendar-month-grid {
        min-width: 420px; /* 7 × 60px = 420 */
        gap: 2px;
    }

    .cal-header {
        font-size: 11px;
        padding: 6px 2px;
    }

    .cal-day {
        min-height: 72px;
        padding: 4px 3px;
    }

    .cal-day-empty {
        min-height: 72px;
    }

    .cal-day-number {
        font-size: 12px;
    }

    .cal-day-month {
        display: none; /* hide "jan", "feb" — date is clear from the column */
    }

    .slot-button,
    .slot-unavailable {
        height: 26px;
        font-size: 10px;
        line-height: 26px;
        padding: 0 2px;
    }

    /* Selection panel: stack info above buttons */
    .selection-panel-inner {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 14px;
        gap: 8px;
    }

    .selection-actions {
        justify-content: space-between;
    }

    .selection-actions .button {
        flex: 1;
    }

    /* Modal slides up from bottom */
    .appointment-modal.is-open {
        display: flex !important;
        flex-direction: column;
        justify-content: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 14px 14px 0 0;
        max-height: 92vh;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0.6; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    .modal-close {
        right: 16px;
        top: 14px;
        font-size: 24px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .button {
        width: 100%;
    }

    .calendar-nav-header h3 {
        font-size: 15px;
    }
}

/* Extra small screens — shrink wrapper padding */
@media (max-width: 380px) {
    .appointment-scheduler-wrapper {
        padding: 6px;
    }

    .appointment-calendar {
        padding: 8px 6px;
    }

    .calendar-month {
        margin: 0 -6px;
        padding: 0 6px;
    }
}

/* Loading State */
.appointment-calendar.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Selection Panel */
.selection-panel {
    position: sticky;
    bottom: 0;
    z-index: 1000;
    background: #b51782;
    color: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
    margin-top: 20px;
}

.selection-panel-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 20px;
    flex-wrap: wrap;
}

.selection-info {
    flex: 1;
}

.selection-count {
    font-size: 16px;
    font-weight: 600;
}

.selection-list {
    list-style: disc;
    margin: 6px 0 0 20px;
    padding: 0;
    font-size: 13px;
    opacity: 0.9;
}

.selection-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.selection-clear {
    background: transparent !important;
    color: white !important;
    border: 1px solid rgba(255,255,255,0.6) !important;
}

.selection-clear:hover {
    background: rgba(255,255,255,0.15) !important;
}

/* Modal slots list */
#modal-slots-list {
    list-style: disc;
    margin: 6px 0 15px 20px;
    padding: 0;
    font-size: 14px;
    color: #333;
}

/* Modal appointment info */
.modal-appointment-info {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.modal-appointment-info p {
    margin: 0 0 4px;
    color: #333;
    font-weight: 600;
}

/* Radio group */
.field-label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

/* Select styling */
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.appointment-calendar.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #297233;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
