/* SAMS Forms CSS */

/* Global h1 styling to fix browser warnings */
h1 {
    font-size: 2.5em;
    margin: 0 0 20px 0;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.2;
}

/* Form Container */
.sams-form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/**
 * SAMS Custom Forms Styles
 */

.sams-form {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sams-form h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    text-align: center;
}

.sams-form-group {
    margin-bottom: 20px;
}

.sams-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #34495e;
}

.sams-form-group label.required::after {
    content: " *";
    color: #e74c3c;
}

.sams-form-group input,
.sams-form-group select,
.sams-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.sams-form-group input:focus,
.sams-form-group select:focus,
.sams-form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

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

.sams-form-row {
    display: flex;
    gap: 15px;
}

.sams-form-row .sams-form-group {
    flex: 1;
}

.sams-submit-btn {
    background: #3498db;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.sams-submit-btn:hover {
    background: #2980b9;
}

.sams-submit-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Form Messages */
.sams-form-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-weight: bold;
}

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

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

.sams-form-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.sams-form-loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.sams-form-loading::before {
    content: "⏳ Submitting...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    font-weight: bold;
    color: #2c3e50;
}

.sams-course-search {
    position: relative;
}

.sams-course-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.sams-course-suggestion {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.sams-course-suggestion:hover {
    background: #f8f9fa;
}

.sams-course-suggestion:last-child {
    border-bottom: none;
}

.sams-required-note {
    margin-bottom: 20px;
    font-style: italic;
    color: #7f8c8d;
    text-align: center;
}

.field-error {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 5px;
}

/* Country Selector and Program Filter */
.sams-form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.sams-form-group select optgroup {
    font-weight: bold;
    color: #3498db;
}

.sams-form-group select option {
    font-weight: normal;
    color: #2c3e50;
}

.sams-form-group select:focus {
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Loading state for selects */
.sams-form-group select.loading {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24' stroke='%232c3e50' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'%3e%3cline x1='12' y1='2' x2='12' y2='6'%3e%3c/line%3e%3cline x1='12' y1='18' x2='12' y2='22'%3e%3c/line%3e%3cline x1='4.93' y1='4.93' x2='7.76' y2='7.76'%3e%3c/line%3e%3cline x1='16.24' y1='16.24' x2='19.07' y2='19.07'%3e%3c/line%3e%3cline x1='2' y1='12' x2='6' y2='12'%3e%3c/line%3e%3cline x1='18' y1='12' x2='22' y2='12'%3e%3c/line%3e%3cline x1='4.93' y1='19.07' x2='7.76' y2='16.24'%3e%3c/line%3e%3cline x1='16.24' y1='7.76' x2='19.07' y2='4.93'%3e%3c/line%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

/* Selected Program Info */
.selected-program-info {
    background-color: #f8f9fa;
    border-left: 4px solid #3498db;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.selected-program-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 16px;
}

.selected-program-info p {
    margin: 0;
    line-height: 1.5;
    color: #34495e;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sams-form {
        padding: 20px;
        margin: 10px;
    }
    
    .sams-form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* Ensure date inputs are properly styled and visible */
.sams-form-group input[type="date"] {
    color: #2c3e50 !important;
    background: #ffffff !important;
    border: 2px solid #ddd !important;
    padding: 12px !important;
    min-height: 44px !important;
    font-size: 16px !important;
    font-family: inherit !important;
    border-radius: 4px !important;
}

.sams-form-group input[type="date"]:focus {
    border-color: #3498db !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2) !important;
    background: #ffffff !important;
}

/* Save Draft Button Styling */
.sams-save-draft-btn {
    background: #38b2ac;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-right: 10px;
}

.sams-save-draft-btn:hover {
    background: #319795;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 178, 172, 0.3);
}

.sams-save-draft-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Mobile-specific optimizations and error handling */
@media (max-width: 768px) {
    .sams-form {
        padding: 15px;
        margin: 10px;
    }
    
    .sams-form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .sams-form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .sams-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Better for mobile touch */
    }
    
    /* Mobile-specific error messages */
    .sams-mobile-alert {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        border: 2px solid #e74c3c;
        border-radius: 8px;
        padding: 20px;
        max-width: 90%;
        max-height: 80%;
        overflow-y: auto;
        z-index: 10000;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    }
    
    .sams-mobile-alert h4 {
        margin: 0 0 15px 0;
        color: #e74c3c;
        font-size: 18px;
    }
    
    .sams-mobile-alert p {
        margin: 10px 0;
        line-height: 1.5;
    }
    
    .sams-mobile-alert ul {
        margin: 10px 0;
        padding-left: 20px;
    }
    
    .sams-mobile-alert li {
        margin: 5px 0;
        line-height: 1.4;
    }
    
    .sams-mobile-alert .sams-btn {
        margin-top: 15px;
        background: #3498db;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 5px;
        cursor: pointer;
    }
    
    .sams-mobile-alert .sams-btn:hover {
        background: #2980b9;
    }
    
    /* Enhanced form loading states for mobile */
    .sams-form-loading {
        position: relative;
        opacity: 0.7;
        pointer-events: none;
    }
    
    .sams-form-loading::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255,255,255,0.8);
        z-index: 1000;
    }
    
    /* Better touch targets */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        min-height: 44px; /* iOS minimum touch target */
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Improved error visibility on mobile */
    .field-error {
        font-size: 14px !important;
        margin-top: 5px !important;
        color: #e74c3c !important;
        background: #fdf2f2;
        padding: 8px;
        border-radius: 4px;
        border-left: 3px solid #e74c3c;
    }
    
    .sams-form-message {
        margin: 15px 0;
        padding: 12px;
        border-radius: 6px;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .sams-form-message.success {
        background: #d4edda;
        border: 1px solid #c3e6cb;
        color: #155724;
    }
    
    .sams-form-message.error {
        background: #f8d7da;
        border: 1px solid #f5c6cb;
        color: #721c24;
    }
    
    /* Network status indicator */
    .sams-network-status {
        position: fixed;
        top: 10px;
        right: 10px;
        background: rgba(0,0,0,0.8);
        color: white;
        padding: 8px 12px;
        border-radius: 20px;
        font-size: 12px;
        z-index: 9999;
        display: none;
    }
    
    .sams-network-status.offline {
        display: block;
        background: rgba(231, 76, 60, 0.9);
    }
    
    .sams-network-status.online {
        display: block;
        background: rgba(46, 204, 113, 0.9);
    }
}

/* Network error specific styles */
.sams-network-error {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.sams-network-error h4 {
    margin: 0 0 10px 0;
    color: #856404;
}

.sams-network-error ul {
    margin: 10px 0;
    padding-left: 20px;
}

.sams-network-error li {
    margin: 5px 0;
}

/* Timeout error specific styles */
.sams-timeout-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.sams-timeout-error h4 {
    margin: 0 0 10px 0;
    color: #721c24;
}

/* Enhanced loading indicators */
.sams-loading-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Retry button styles */
.sams-retry-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 14px;
}

.sams-retry-btn:hover {
    background: #2980b9;
}

/* Connection quality indicator */
.sams-connection-quality {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    z-index: 9998;
    display: none;
}

.sams-connection-quality.excellent {
    background: #27ae60;
    display: block;
}

.sams-connection-quality.good {
    background: #f39c12;
    display: block;
}

.sams-connection-quality.poor {
    background: #e74c3c;
    display: block;
}

/* Mobile-specific form optimizations */
@media (max-width: 480px) {
    .sams-form {
        padding: 10px;
        margin: 5px;
    }
    
    .sams-form-row {
        gap: 10px;
    }
    
    .sams-btn {
        padding: 15px;
        font-size: 16px;
        margin: 5px 0;
    }
    
    /* Prevent horizontal scrolling */
    .sams-form-container {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Better spacing for mobile */
    .sams-form-group {
        margin-bottom: 15px;
    }
    
    .sams-form-label {
        display: block;
        margin-bottom: 5px;
        font-weight: 600;
    }
    
    /* Improved mobile input styling */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 12px;
        font-size: 16px;
    }
    
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="tel"]:focus,
    input[type="password"]:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: #3498db;
        box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
    }
}
