/* ============================================================================
   Supplier Registration V2 - Mobile-First Styles
   ============================================================================ */

/* ============================================================================
   MODAL CONTAINER
   ============================================================================ */

.supplier-registration-v2 {
    max-width: 640px;
    width: 100%;
    max-height: 95vh;
    overflow-y: auto;
    border-radius: 20px;
    background: #ffffff;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .supplier-registration-v2 {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        animation: modalSlideUp 0.3s ease-out;
    }
    
    @keyframes modalSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ============================================================================
   REGISTRATION HEADER
   ============================================================================ */

.registration-header {
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.registration-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.registration-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.supplier-registration-v2 .registration-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #ffffff !important;
    margin: 0 0 0.5rem 0;
    position: relative;
    z-index: 1;
}

/* Ensure supplier registration modal title is white */
#supplierRegistrationModal .registration-header h2,
.modal-overlay .supplier-registration-v2 .registration-header h2 {
    color: #ffffff !important;
}

.registration-tagline {
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    position: relative;
    z-index: 1;
}

@media (max-width: 480px) {
    .registration-header {
        padding: 1.5rem 1rem;
    }
    
    .supplier-registration-v2 .registration-header h2 {
        font-size: 1.5rem;
    }
    
    .registration-tagline {
        font-size: 0.875rem;
    }
}

/* ============================================================================
   PROGRESS INDICATOR
   ============================================================================ */

.registration-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    right: -50%;
    height: 2px;
    background: #cbd5e1;
    z-index: -1;
}

.progress-step.completed:not(:last-child)::after,
.progress-step.active:not(:last-child)::after {
    background: #10b981;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.progress-step.active .step-number {
    background: #10b981;
    color: #ffffff;
    transform: scale(1.1);
}

.progress-step.completed .step-number {
    background: #10b981;
    color: #ffffff;
}

.progress-step.completed .step-number::after {
    content: '✓';
    font-size: 1.2rem;
}

.step-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-align: center;
}

.progress-step.active .step-label,
.progress-step.completed .step-label {
    color: #10b981;
}

@media (max-width: 480px) {
    .registration-progress {
        padding: 1rem 0.5rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
    
    .step-label {
        font-size: 0.625rem;
    }
}

/* ============================================================================
   FORM CONTAINER
   ============================================================================ */

.supplier-form-v2 {
    padding: 1.5rem;
}

/* Ensure form is visible */
#supplierRegistrationModal .supplier-form-v2,
.modal-content.supplier-registration-v2 .supplier-form-v2 {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

@media (max-width: 480px) {
    .supplier-form-v2 {
        padding: 1rem;
    }
}

/* ============================================================================
   FORM STEPS
   ============================================================================ */

/* Ensure form steps are hidden by default */
#supplierRegistrationModal .form-step,
.modal-content.supplier-registration-v2 .form-step {
    display: none !important;
    opacity: 0;
    visibility: hidden;
}

/* Ensure active form step is visible */
#supplierRegistrationModal .form-step.active,
.modal-content.supplier-registration-v2 .form-step.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    animation: fadeIn 0.3s ease-in;
}

/* Legacy selectors for backwards compatibility */
.form-step {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.form-step.active {
    display: block;
}

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

.step-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
}

@media (max-width: 480px) {
    .step-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
}

/* ============================================================================
   FORM GROUPS & INPUTS
   ============================================================================ */

.form-group {
    margin-bottom: 1.25rem;
}

/* Custom category container - smooth transition */
#sr-otherCategoryContainer {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 100px;
    }
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.required {
    color: #ef4444;
}

.form-hint-inline {
    color: #64748b;
    font-weight: 400;
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    transform: translateY(-1px);
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

.form-group.error input,
.form-group.error select,
.form-group.error textarea {
    border-color: #ef4444;
    background: #fef2f2;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.error-message::before {
    content: '⚠';
    font-size: 1rem;
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

/* ============================================================================
   INLINE PAIRS (two fields side-by-side)
   ============================================================================ */

.inline-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .inline-pair {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* ============================================================================
   RADIO & CHECKBOX GROUPS
   ============================================================================ */

.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-label,
.check-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.radio-label:hover,
.check-label:hover {
    background: #f1f5f9;
}

input[type="radio"],
input[type="checkbox"] {
    width: auto;
    min-width: 18px;
    min-height: 18px;
    cursor: pointer;
}

/* ============================================================================
   SEARCHABLE MULTI-SELECT
   ============================================================================ */

.searchable-multiselect {
    position: relative;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    padding: 0.75rem;
}

.sms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sms-search {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9375rem;
}

.sms-count-badge {
    background: #10b981;
    color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.sms-options {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.sms-option {
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f1f5f9;
}

.sms-option:last-child {
    border-bottom: none;
}

.sms-option:hover {
    background: #f1f5f9;
}

.sms-option.selected {
    background: #d1fae5;
    font-weight: 600;
    color: #065f46;
}

.sms-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    background: #10b981;
    color: #ffffff;
    padding: 0.375rem 0.75rem;
    border-radius: 16px;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.chip-remove {
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.chip-remove:hover {
    opacity: 0.7;
}

/* ============================================================================
   PRODUCT LIST & CARDS
   ============================================================================ */

.product-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.product-card {
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.product-card:hover {
    border-color: #10b981;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.1);
    transform: translateY(-2px);
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.product-name {
    font-weight: 600;
    font-size: 1rem;
    color: #1e293b;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.btn-icon:hover {
    background: #e2e8f0;
}

.product-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.product-detail-item {
    font-size: 0.875rem;
}

.product-detail-item .label {
    color: #64748b;
    display: block;
    margin-bottom: 0.125rem;
}

.product-detail-item .value {
    font-weight: 600;
    color: #1e293b;
}

.stock-status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stock-status-badge.in_stock {
    background: #d1fae5;
    color: #065f46;
}

.stock-status-badge.limited_stock {
    background: #fef3c7;
    color: #92400e;
}

.stock-status-badge.out_of_stock {
    background: #fee2e2;
    color: #991b1b;
}

.stock-status-badge.made_to_order {
    background: #dbeafe;
    color: #1e40af;
}

.btn-add-product {
    width: 100%;
    padding: 0.875rem;
    border: 2px dashed #cbd5e1;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    font-size: 1rem;
}

.btn-add-product:hover {
    border-color: #10b981;
    color: #10b981;
    background: #f0fdf4;
}

/* ============================================================================
   PRODUCT ENTRY FORM (MODAL/INLINE)
   ============================================================================ */

.product-entry-form {
    border: 2px solid #10b981;
    border-radius: 12px;
    padding: 1.5rem;
    background: #f0fdf4;
    margin-top: 1rem;
}

.product-entry-form h4 {
    margin: 0 0 1rem 0;
    color: #065f46;
    font-size: 1.125rem;
}

.product-form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-cancel-product,
.btn-save-product {
    flex: 1;
    padding: 0.875rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    border: none;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.btn-cancel-product {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-cancel-product:hover {
    background: #f8fafc;
}

.btn-save-product {
    background: #10b981;
    color: #ffffff;
}

.btn-save-product:hover {
    background: #059669;
}

@media (max-width: 480px) {
    .product-form-actions {
        flex-direction: column;
    }
}

/* ============================================================================
   DOCUMENT & CERTIFICATION LISTS
   ============================================================================ */

.document-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.document-card {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 1rem;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-info {
    flex: 1;
}

.document-type {
    font-weight: 600;
    color: #1e293b;
}

.document-number {
    font-size: 0.875rem;
    color: #64748b;
}

.btn-add-doc {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #cbd5e1;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: all 0.2s ease;
}

.btn-add-doc:hover {
    border-color: #10b981;
    color: #10b981;
}

.document-entry-form {
    border: 2px solid #3b82f6;
    border-radius: 12px;
    padding: 1.5rem;
    background: #eff6ff;
    margin-top: 1rem;
}

/* ============================================================================
   REVIEW SUMMARY (STEP 5)
   ============================================================================ */

.review-summary {
    margin-bottom: 2rem;
}

.summary-section {
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    background: #f9fafb;
}

.summary-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-link {
    color: #10b981;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.edit-link:hover {
    color: #059669;
    text-decoration: underline;
}

.summary-row {
    display: flex;
    margin-bottom: 0.75rem;
}

.summary-row .label {
    flex: 0 0 40%;
    color: #64748b;
    font-size: 0.875rem;
}

.summary-row .value {
    flex: 1;
    color: #1e293b;
    font-weight: 500;
}

@media (max-width: 480px) {
    .summary-row {
        flex-direction: column;
    }
    
    .summary-row .label {
        margin-bottom: 0.25rem;
    }
}

.terms-group {
    border-top: 1px solid #e2e8f0;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.terms-check {
    padding: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.terms-check a {
    color: #10b981;
    text-decoration: underline;
}

/* ============================================================================
   FORM NAVIGATION
   ============================================================================ */

.form-navigation {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #ffffff 90%, rgba(255, 255, 255, 0.8) 100%);
    border-top: 1px solid #e2e8f0;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    z-index: 50;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.btn-prev,
.btn-next,
.btn-submit {
    padding: 1rem 1.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    min-width: 120px;
    font-size: 1rem;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-prev {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    color: #475569;
}

.btn-prev:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-next,
.btn-submit {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-next:hover,
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

.btn-next:active,
.btn-submit:active {
    transform: translateY(0);
}

.btn-next:disabled,
.btn-submit:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

@media (max-width: 480px) {
    .form-navigation {
        flex-direction: column-reverse;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .btn-prev,
    .btn-next,
    .btn-submit {
        width: 100%;
        min-width: 100%;
    }
}

/* ============================================================================
   LOADING SPINNER
   ============================================================================ */

.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-text {
    margin-top: 1rem;
    color: #64748b;
    font-weight: 600;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ============================================================================
   MODAL CLOSE BUTTON
   ============================================================================ */

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg) scale(1.1);
}

.modal-close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

/* Mobile optimization for touch targets */
@media (max-width: 768px) {
    .modal-close-btn {
        width: 44px;
        height: 44px;
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* ============================================================================
   SMOOTH SCROLLING FOR MODAL
   ============================================================================ */

.supplier-registration-v2 {
    scroll-behavior: smooth;
}

.supplier-registration-v2::-webkit-scrollbar {
    width: 8px;
}

.supplier-registration-v2::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.supplier-registration-v2::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.supplier-registration-v2::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================================================
   ENHANCED LOADING SPINNER
   ============================================================================ */

.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 4px solid #e2e8f0;
    border-top-color: #10b981;
    border-right-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-text {
    margin-top: 1.5rem;
    color: #1e293b;
    font-weight: 600;
    font-size: 1.125rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* Focus visible for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid #10b981;
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
