/* Custom Calendar Widget - Mobile-First Design */
.sg-calendar-wrapper {
    margin: 20px 0;
    font-family: Arial, sans-serif;
    position: relative;
}

.sg-calendar-header {
    margin-bottom: 10px;
}

.sg-calendar-header label {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    display: block;
    margin-bottom: 5px;
}

.sg-calendar-note {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    line-height: 1.3;
}

/* Input wrapper with icons */
.sg-calendar-input-wrapper {
    position: relative;
    display: block;
    width: 100%;
    max-width: 300px;
    margin-bottom: 30px; /* Space for error messages */
}

.sg-calendar-input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #B88452;
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    cursor: pointer;
    background-color: #fff;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    border-radius: 0px !important;
}

.sg-calendar-input:focus {
    outline: none;
    border-color: #B88452;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.sg-calendar-input::placeholder {
    color: #999;
    font-style: italic;
}

/* Calendar and clear icons */
.sg-calendar-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    cursor: pointer;
    user-select: none;
    color: #B88452;
    z-index: 10;
    padding: 5px;
}

.sg-calendar-icon:hover {
    color: #000000;
}


/* Calendar widget */
.sg-calendar-widget {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    padding: 15px;
    min-width: 280px;
    margin-top: 6px;
    user-select: none;
}

@media (max-width: 768px) {
    .sg-calendar-widget {
        max-width: 340px;
        padding: 12px;
    }
    
    .sg-calendar-grid {
        width: 100%;
        box-sizing: border-box;
    }
    
    .sg-calendar-weekdays {
        gap: 2px;
        margin-bottom: 8px;
    }
    
    .sg-calendar-weekdays > div {
        padding: 6px 2px;
        font-size: 11px;
        min-width: 0;
        word-break: break-word;
    }
    
    .sg-calendar-days {
        gap: 2px;
    }
    
    .sg-calendar-day {
        min-height: 38px;
        min-width: 38px;
        max-width: 42px;
        padding: 4px 2px;
        font-size: 13px;
        box-sizing: border-box;
    }
}

/* Calendar navigation */
.sg-calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.sg-calendar-nav button {
    background: #B88452;
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    min-width: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.sg-calendar-nav button:hover:not(:disabled) {
    background: #222;
}

.sg-calendar-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sg-current-month {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    text-align: center;
    flex: 1;
    margin: 0 12px;
}

/* Calendar grid */
.sg-calendar-grid {
    width: 100%;
}

.sg-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 10px;
}

.sg-calendar-weekdays > div {
    text-align: center;
    font-weight: bold;
    padding: 8px 6px;
    background: #f8f9fa;
    color: #000000;
    font-size: 12px;
    border-radius: 3px;
    font-weight: 600;
}

.sg-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

/* Individual day cells */
.sg-calendar-day {
    text-align: center;
    padding: 8px 6px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    background: #f9f9f9;
    color: #333;
    transition: all 0.2s ease;
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    font-weight: 500;
}

.sg-calendar-day:hover:not(.sg-past-date):not(.sg-other-month) {
    background: #e6e1d6ad;
    color: #B88452;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px #e6e1d6ad;
}

.sg-calendar-day:focus {
    outline: none;
    border-color: #B88452;
    box-shadow: 0 0 0 2px #e6e1d6ad;
}

.sg-calendar-day.sg-selected {
    background: #B88452;
    color: white;
    font-weight: bold;
}

.sg-calendar-day.sg-selected:hover {
    background: #005a87;
    transform: translateY(-1px);
}

.sg-calendar-day.sg-other-month {
    color: transparent;
    background: transparent;
    cursor: default;
}

.sg-calendar-day.sg-past-date {
    color: #ccc;
    background: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.6;
    position: relative;
}

.sg-calendar-day.sg-past-date:hover {
    background: #f0f0f0;
    color: #ccc;
    transform: none;
    box-shadow: none;
}

/* Disabled dates styling - no strikethrough, just grayed out */

/* Error messages */
.sg-date-error {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    padding: 10px 12px;
    border-radius: 0px;
    font-size: 13px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    animation: fadeIn 0.3s ease-in;
    text-align: center;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* Mobile-specific styles for larger mobile screens */
@media (min-width: 481px) and (max-width: 768px) {
    .sg-calendar-input-wrapper {
        max-width: 100%;
    }
    
    .sg-calendar-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 15px 50px 15px 15px;
    }
    
    .sg-calendar-icon {
        right: 12px;
        font-size: 22px;
        padding: 8px;
    }
    
    /* Modal behavior for mobile */
    .sg-calendar-widget.sg-calendar-modal {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 340px;
        max-height: 80vh;
        overflow-y: auto;
        z-index: 9999;
        margin: 0;
        animation: modalSlideIn 0.3s ease-out;
    }
    
    @keyframes modalSlideIn {
        from {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }
    
    /* Ensure touch targets are large enough - only for larger mobile screens */
    
    .sg-calendar-nav button {
        min-width: 48px;
        min-height: 48px;
        font-size: 18px;
    }
    
    .sg-current-month {
        font-size: 16px;
    }
    
    .sg-calendar-weekdays > div {
        padding: 10px 4px;
        font-size: 12px;
    }
}

/* Small mobile screens - compact calendar */
@media (max-width: 480px) {
    .sg-calendar-input-wrapper {
        max-width: 100%;
    }
    
    .sg-calendar-input {
        font-size: 16px;
        padding: 15px 50px 15px 15px;
    }
    
    .sg-calendar-icon {
        right: 12px;
        font-size: 22px;
        padding: 8px;
    }
    
    .sg-calendar-widget.sg-calendar-modal {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 340px;
        max-height: 80vh;
        overflow-y: auto;
        z-index: 9999;
        margin: 0;
        animation: modalSlideIn 0.3s ease-out;
        padding: 12px;
    }
    
    .sg-calendar-grid {
        width: 100%;
        box-sizing: border-box;
    }
    
    .sg-calendar-weekdays {
        gap: 2px;
        margin-bottom: 8px;
    }
    
    .sg-calendar-weekdays > div {
        padding: 6px 2px;
        font-size: 11px;
        min-width: 0;
        word-break: break-word;
    }
    
    .sg-calendar-days {
        gap: 2px;
    }
    
    .sg-calendar-day {
        min-height: 38px;
        min-width: 38px;
        max-width: 42px;
        padding: 4px 2px;
        font-size: 13px;
        box-sizing: border-box;
    }
    
    .sg-calendar-nav button {
        min-width: 44px;
        min-height: 44px;
        font-size: 16px;
    }
    
    .sg-current-month {
        font-size: 15px;
        margin: 0 10px;
    }
    
    .sg-calendar-nav {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sg-calendar-input {
        border-width: 3px;
    }
    
    .sg-calendar-day:focus {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sg-calendar-day,
    .sg-calendar-nav button,
    .sg-calendar-input,
    .sg-clear-date {
        transition: none;
    }
    
    .sg-calendar-day:hover:not(.sg-past-date):not(.sg-other-month) {
        transform: none;
    }
    
    .sg-calendar-day.sg-selected:hover {
        transform: none;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes modalSlideIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .sg-calendar-widget {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .sg-calendar-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .sg-calendar-input::placeholder {
        color: #a0aec0;
    }
    
    .sg-calendar-day {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .sg-calendar-day:hover:not(.sg-past-date):not(.sg-other-month) {
        background: #2b6cb0;
        color: white;
    }
    
    .sg-calendar-weekdays > div {
        background: #4a5568;
        color: #a0aec0;
    }
    
    .sg-current-month {
        color: #e2e8f0;
    }
}