/* ID Form Manager Frontend Styles */

:root {
    --ifm-primary: #0073aa;
    --ifm-success: #28a745;
    --ifm-danger: #dc3545;
    --ifm-warning: #ffc107;
    --ifm-info: #17a2b8;
    --ifm-light: #f8f9fa;
    --ifm-dark: #343a40;
    --ifm-border: #dee2e6;
    --ifm-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --ifm-radius: 6px;
    --ifm-transition: all 0.3s ease;
}

/* RTL Support */
.ifm-user-form {
    direction: rtl;
    text-align: right;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* Form Container */
.ifm-form-container {
    background: var(--ifm-light);
    border-radius: var(--ifm-radius);
    box-shadow: var(--ifm-shadow);
    padding: 30px;
    margin-bottom: 20px;
}

.ifm-form-container h3 {
    color: var(--ifm-primary);
    text-align: center;
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 600;
}

/* Form Fields */
.ifm-form-group {
    margin-bottom: 20px;
}

.ifm-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--ifm-dark);
    font-size: 14px;
}

.ifm-form-group .required {
    color: var(--ifm-danger);
    margin-right: 3px;
}

.ifm-input,
.ifm-select,
.ifm-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--ifm-border);
    border-radius: var(--ifm-radius);
    font-size: 16px;
    font-family: inherit;
    transition: var(--ifm-transition);
    background-color: white;
}

.ifm-input:focus,
.ifm-select:focus,
.ifm-textarea:focus {
    outline: none;
    border-color: var(--ifm-primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.ifm-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.ifm-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--ifm-radius);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--ifm-transition);
    text-align: center;
    line-height: 1.5;
}

.ifm-btn-primary {
    background-color: var(--ifm-primary);
    color: white;
}

.ifm-btn-primary:hover {
    background-color: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.3);
}

.ifm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Form Actions */
.ifm-form-actions {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--ifm-border);
}

.ifm-loading {
    color: var(--ifm-primary);
    font-weight: 600;
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ifm-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--ifm-border);
    border-top: 2px solid var(--ifm-primary);
    border-radius: 50%;
    animation: ifm-spin 1s linear infinite;
}

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

/* Field Errors */
.ifm-field-error {
    color: var(--ifm-danger);
    font-size: 14px;
    margin-top: 5px;
    display: block;
}

/* Messages */
.ifm-message {
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: var(--ifm-radius);
    font-weight: 600;
    border: 1px solid transparent;
}

.ifm-message.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.ifm-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.ifm-message.warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

/* Preview Container */
.ifm-preview-container {
    background: white;
    border-radius: var(--ifm-radius);
    box-shadow: var(--ifm-shadow);
    padding: 20px;
    text-align: center;
}

.ifm-preview-container h4 {
    color: var(--ifm-primary);
    margin-bottom: 20px;
    font-size: 18px;
}

.ifm-id-preview {
    position: relative;
    display: inline-block;
    border: 2px solid var(--ifm-border);
    border-radius: var(--ifm-radius);
    overflow: hidden;
    background: white;
    box-shadow: var(--ifm-shadow);
    max-width: 100%;
}

.ifm-template-bg {
    max-width: 100%;
    height: auto;
    display: block;
}

.ifm-preview-text {
    position: absolute;
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #000;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--ifm-border);
    pointer-events: none;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barcode Field Enhancements */
.ifm-barcode-field {
    position: relative;
}

.ifm-barcode-loading,
.ifm-barcode-success {
    font-size: 12px;
    margin-right: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

.ifm-barcode-loading {
    color: var(--ifm-warning);
    background: #fff3cd;
}

.ifm-barcode-success {
    color: var(--ifm-success);
    background: #d4edda;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ifm-user-form {
        flex-direction: column;
        padding: 15px;
    }
    
    .ifm-form-container,
    .ifm-preview-container {
        min-width: auto;
        margin-bottom: 20px;
    }
    
    .ifm-form-container {
        padding: 20px;
    }
    
    .ifm-input,
    .ifm-select,
    .ifm-textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ifm-btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .ifm-preview-container {
        order: -1; /* Show preview first on mobile */
    }
}

@media (max-width: 480px) {
    .ifm-form-container h3 {
        font-size: 20px;
    }
    
    .ifm-form-container {
        padding: 15px;
    }
    
    .ifm-id-preview {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Print Styles */
@media print {
    .ifm-user-form {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .ifm-btn,
    .ifm-loading {
        display: none;
    }
    
    .ifm-form-container,
    .ifm-preview-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Accessibility Improvements */
.ifm-input:focus,
.ifm-select:focus,
.ifm-textarea:focus {
    outline: 2px solid var(--ifm-primary);
    outline-offset: 2px;
}

.ifm-btn:focus {
    outline: 2px solid var(--ifm-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ifm-input,
    .ifm-select,
    .ifm-textarea {
        border-width: 3px;
    }
    
    .ifm-btn-primary {
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --ifm-light: #2d3748;
        --ifm-dark: #e2e8f0;
        --ifm-border: #4a5568;
    }
    
    .ifm-form-container,
    .ifm-preview-container {
        background: var(--ifm-light);
        color: var(--ifm-dark);
    }
    
    .ifm-input,
    .ifm-select,
    .ifm-textarea {
        background-color: #4a5568;
        color: var(--ifm-dark);
        border-color: #718096;
    }
}
