/* ===== CERTIFICATE FORM - Main Container ===== */
.cert-form {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 8px;
}

/* ===== Header ===== */
.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2937;
}

.header-right {
    display: flex;
    align-items: center;
}

.cert-number-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e40af;
    background: #dbeafe;
    padding: 6px 16px;
    border-radius: 8px;
    letter-spacing: 1px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-usa { background: #dbeafe; color: #1e40af; }
.badge-mx { background: #dcfce7; color: #166534; }
.badge-trucks { background: #fed7aa; color: #c2410c; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert ul {
    margin: 6px 0 0 16px;
    padding: 0;
}

.alert li {
    font-size: 0.85rem;
}

.alert.compact {
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

/* ===== Service Selector ===== */
.service-selector {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.service-selector > label {
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
    white-space: nowrap;
}

.service-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.service-row select {
    flex: 1;
    max-width: 320px;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
}

.service-row select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.btn-validate-caaarem {
    background: #f59e0b;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-validate-caaarem:hover:not(:disabled) {
    background: #d97706;
}

.btn-validate-caaarem:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.caaarem-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dcfce7;
    color: #166534;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-back {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-back:hover {
    background: #f3f4f6;
}

.caaarem-approved-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dcfce7;
    color: #166534;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ===== CAAAREM Pre-validation ===== */
.caaarem-section {
    margin-bottom: 20px;
}

.caaarem-card {
    background: #fffbeb;
    border: 2px solid #fcd34d;
    border-radius: 12px;
    padding: 24px;
}

.caaarem-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: #92400e;
}

.caaarem-card p {
    margin: 0 0 16px 0;
    color: #78716c;
    font-size: 0.9rem;
}

.caaarem-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.caaarem-vin {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.caaarem-vin:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.btn-caaarem {
    background: #f59e0b;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-caaarem:hover:not(:disabled) {
    background: #d97706;
}

.btn-caaarem:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.caaarem-validation-box {
    margin-top: 14px;
    background: #fffbeb;
    border: 2px solid #fcd34d;
    border-radius: 10px;
    padding: 16px 20px;
}

.caaarem-instruction {
    margin: 0 0 12px 0;
    color: #92400e;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== 2-Column Grid ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== Cards ===== */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card h3 {
    margin: 0 0 16px 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #374151;
    padding-bottom: 10px;
    border-bottom: 1px solid #f3f4f6;
}

/* ===== Fields ===== */
.field {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.field input,
.field select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.field-row {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.field-btn {
    flex: 0 0 auto;
}

.flex-grow {
    flex: 1;
}

/* ===== Disabled / Locked Fields ===== */
.disabled-field {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
    cursor: not-allowed;
    border-color: #e5e7eb !important;
}

.cert-num {
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== Input Validation ===== */
.input-valid {
    border-color: #22c55e !important;
}

.char-count {
    font-size: 0.7rem;
    color: #9ca3af;
    text-align: right;
    margin-top: 2px;
}

/* ===== Monitors Grid ===== */
.monitors-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.monitor {
    display: flex;
    flex-direction: column;
}

.monitor label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.monitor select {
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}

.monitor select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.monitor-overall {
    grid-column: span 3;
}

.monitor-overall select {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 9px 12px;
}

.select-pass {
    background-color: #dcfce7 !important;
    border-color: #22c55e !important;
    color: #166534;
}

.select-fail {
    background-color: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b;
}

.btn-pass {
    background: #22c55e;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-pass:hover {
    background: #16a34a;
}

/* ===== Location ===== */
.location-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.location-fields {
    flex: 1;
    min-width: 0;
}

.location-fields .field select {
    width: 100%;
}

.location-map {
    flex: 0 0 280px;
}

.location-map img {
    width: 280px;
    max-height: 200px;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.location-address {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.5;
}

/* ===== Image Upload Grid ===== */
.image-grid {
    display: grid;
    /* auto-fit con minmax — se adapta al ancho disponible.
       En pantallas anchas → 4 columnas (8 slots en 2 filas)
       En pantallas medias → 3 columnas
       En móvil → 2 columnas
       Garantiza que TODOS los slots sean visibles sin overflow */
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.image-slot {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    background: #fafafa;
}

.image-slot:hover {
    border-color: #3b82f6;
    background: #f0f7ff;
}

.image-slot.has-image {
    border-color: #22c55e;
    border-style: solid;
    background: #f0fdf4;
}

.image-slot label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
}

.image-preview {
    width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
}

.image-slot ::deep input[type="file"] {
    width: 100%;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ===== Photo Replace Button ===== */
.btn-replace-photo {
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 4px;
}
.btn-replace-photo:hover {
    background: #d97706;
}
.photo-pending-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}

/* ===== VIN Confirmation Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.15rem;
    color: #1f2937;
}

.modal-content p {
    margin: 0 0 16px 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.vin-confirm-display {
    background: #1f2937;
    color: #22c55e;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.vin-confirm-photo {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== Form Actions ===== */
.form-actions-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 24px 0;
    margin-top: 8px;
}

.btn-large {
    padding: 12px 36px !important;
    font-size: 1rem !important;
    font-weight: 600;
}

/* ===== Buttons (shared) ===== */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-secondary {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
    background: #f3f4f6;
}

/* ===== Download Certificate Button ===== */
.btn-download-cert {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    border: 1px solid #047857;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
}
.btn-download-cert:hover { opacity: 0.9; color: #fff; }
.btn-download-cert.disabled {
    background: #374151;
    border-color: #4b5563;
    color: #6b7280;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.6;
}
.btn-download-cert svg { flex-shrink: 0; }

/* ===== CLAA Button ===== */
.btn-prevalidator {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: #fff;
    border-color: #7c3aed;
}

.btn-prevalidator:hover:not(:disabled) {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

/* ===== Send Status Indicator ===== */
.send-status-indicator {
    font-size: 1.4rem;
    margin-left: 8px;
    vertical-align: middle;
    cursor: help;
}

.status-success { color: #22c55e; }
.status-warning { color: #eab308; }
.status-error { color: #ef4444; }
.status-none { color: #9ca3af; }

.send-hint {
    color: #9ca3af;
    font-size: 0.8rem;
    font-style: italic;
    margin-left: 8px;
}

/* ===== Prevalidator Modal ===== */
.prevalidator-modal {
    border-top: 4px solid #7c3aed;
}

.prevalidator-name-display {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.prevalidator-data-preview {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.prevalidator-data-preview div {
    padding: 4px 0;
    color: #4c1d95;
}

.prevalidator-data-preview strong {
    color: #6d28d9;
}

.resend-warning {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.resend-warning .icon-warning {
    font-size: 1.5rem;
    background: none;
    color: #d97706;
    width: auto;
    height: auto;
}

.resend-warning p {
    margin: 0;
    color: #92400e;
    font-size: 0.9rem;
}

/* ===== Prevalidator Result Modal ===== */
.prevalidator-result-modal {
    text-align: center;
    padding: 30px;
    min-width: 350px;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.prevalidator-result-icon {
    margin-bottom: 20px;
}

.prevalidator-result-icon span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    font-size: 36px;
    font-weight: bold;
}

.icon-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
}

.icon-warning {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    color: #fff;
}

.icon-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.prevalidator-result-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.prevalidator-result-message {
    font-size: 1rem;
    color: #4b5563;
    margin-bottom: 8px;
    line-height: 1.5;
}

.prevalidator-result-service {
    display: block;
    color: #9ca3af;
    margin-bottom: 20px;
}

/* Result modal color variants */
.result-success {
    border-top: 5px solid #22c55e;
}

.result-success .prevalidator-result-title {
    color: #16a34a;
}

.result-warning {
    border-top: 5px solid #eab308;
}

.result-warning .prevalidator-result-title {
    color: #ca8a04;
}

.result-error {
    border-top: 5px solid #ef4444;
}

.result-error .prevalidator-result-title {
    color: #dc2626;
}

/* Result buttons */
.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    border-color: #16a34a;
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    color: #fff;
    border-color: #ca8a04;
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #ca8a04 0%, #a16207 100%);
    box-shadow: 0 4px 12px rgba(202, 138, 4, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    border-color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

/* ===== Validation Modal ===== */
.validation-modal {
    text-align: center;
    border-top: 5px solid #f59e0b;
}

.validation-icon {
    margin-bottom: 16px;
}

.icon-circle.icon-validation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.validation-modal h3 {
    color: #d97706;
    margin: 0 0 8px;
}

.validation-list {
    text-align: left;
    margin: 14px 0;
    padding: 12px 16px 12px 32px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    list-style: none;
}

.validation-list li {
    padding: 4px 0;
    color: #92400e;
    font-size: 0.88rem;
    font-weight: 500;
}

.validation-list li::before {
    content: "•";
    color: #f59e0b;
    font-weight: bold;
    margin-right: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .location-layout {
        flex-direction: column;
    }

    .location-map {
        flex: none;
        width: 100%;
    }

    .location-map img {
        width: 100%;
        max-width: 400px;
    }

    .monitors-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .monitor-overall {
        grid-column: span 2;
    }

    .caaarem-row {
        flex-direction: column;
    }

    .service-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .service-row {
        width: 100%;
    }

    .service-row select {
        max-width: none;
    }
}

/* ===== Section Locking (progressive form) ===== */
.section-locked {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}

.section-locked::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    background: rgba(243, 244, 246, 0.3);
    z-index: 1;
}

/* ===== Documentos Adicionales ===== */
.additional-docs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.doc-slot {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    background: #fafafa;
}

.doc-slot:hover {
    border-color: #3b82f6;
    background: #f0f7ff;
}

.doc-slot.has-doc {
    border-color: #22c55e;
    border-style: solid;
    background: #f0fdf4;
}

.doc-slot label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
}

.doc-preview {
    font-size: 0.8rem;
    color: #166534;
    font-weight: 600;
    padding: 8px;
    background: #dcfce7;
    border-radius: 6px;
    margin-bottom: 8px;
}

.doc-slot ::deep input[type="file"] {
    width: 100%;
    font-size: 0.75rem;
    color: #6b7280;
}

@media (max-width: 600px) {
    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    .field-row {
        flex-direction: column;
        gap: 8px;
    }

    .monitors-grid {
        grid-template-columns: 1fr;
    }

    .monitor-overall {
        grid-column: span 1;
    }

    .form-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .additional-docs {
        grid-template-columns: 1fr;
    }
}
