/* ==========================================================================
   TechnicalDataCard Component Styles
   Story 28.13: Intake Form UX Improvements - R1: Technical Data Card
   Updated: Sprint S5 Story 28.21 - CSS Custom Properties integration

   Features:
   - Visually distinct from editable sections (cyan left border, light background)
   - "Solo lectura" badge in header
   - Essential fields with LiveLink indicators
   - Summary grid and expandable detailed fields
   - Responsive design
   - Uses shared CSS custom properties from field-grid-variables.css
   ========================================================================== */

/* ========== BASE COMPONENT ========== */

.technical-data-card {
    position: relative;
    background: linear-gradient(135deg, var(--field-bg-readonly) 0%, var(--field-bg-editable) 100%);
    border: var(--field-border-width) solid var(--field-border-color);
    border-left: var(--field-border-livelink-width) solid var(--color-livelink);
    border-radius: var(--field-border-radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--field-transition);
}

.technical-data-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.technical-data-card.empty {
    border-left-color: #9ca3af; /* Gray when no data */
}

/* ========== CARD HEADER ========== */

.technical-data-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(6, 182, 212, 0.04);
    border-bottom: 1px solid rgba(6, 182, 212, 0.1);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.technical-data-card .card-header:hover {
    background: rgba(6, 182, 212, 0.08);
}

.technical-data-card .header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.technical-data-card .card-icon {
    color: #06b6d4;
    font-size: 18px;
}

.technical-data-card .card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* ========== READ-ONLY BADGE ========== */

.technical-data-card .read-only-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 100px;
}

.technical-data-card .read-only-badge .oi {
    font-size: 9px;
}

/* ========== EXPAND TOGGLE ========== */

.technical-data-card .expand-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.technical-data-card .expand-toggle:hover {
    background-color: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

.technical-data-card .expand-toggle:focus-visible {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
}

/* Issue #148 — right-side header action group (Edit selection + expand toggle). */
.technical-data-card .card-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

/* Issue #148 — "Edit selection" button on the read-only Mold Card header: re-opens the
   mold/part selection (it does NOT edit catalog data). */
.technical-data-card .moldcard-edit-selection {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--medtronic-blue-interactive, #1010EB);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.technical-data-card .moldcard-edit-selection:hover {
    background-color: var(--selection-hover-bg, #f0f6ff);
    border-color: var(--medtronic-blue-interactive, #1010EB);
}

.technical-data-card .moldcard-edit-selection:focus-visible {
    outline: 2px solid var(--medtronic-blue-interactive, #1010EB);
    outline-offset: 2px;
}

/* ========== CARD BODY ========== */

.technical-data-card .card-body {
    padding: 12px 14px;
}

/* ========== COMPACT 4-COLUMN GRID (Story 28.13 UX, Updated S5) ========== */

.technical-data-card .compact-fields-grid {
    display: grid;
    grid-template-columns: repeat(var(--field-grid-columns), 1fr);
    gap: var(--field-grid-gap);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: var(--field-border-width) solid var(--field-border-color);
}

.technical-data-card .compact-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--field-padding-compact);
    background-color: var(--field-bg-readonly);
    border-radius: var(--field-border-radius-lg);
    border: var(--field-border-width) solid var(--field-border-color);
}

/* ========== FEEDBACK BADGE (Story 28.34b) ========== */
/* Wraps a feedbackable essential field (Condition / Status) so the per-field
   "Reportar dato incorrecto" badge stacks under it without disturbing the 4-column
   grid (the wrapper is the single grid item). When ShowFeedbackBadge is false the
   wrapper renders only the inner field, so the layout is byte-for-byte unchanged (AC6). */
/* #144 — the wrapper is the grid cell's positioning context so the feedback flag can
   sit in a fixed, unobtrusive corner of the cell (bottom-right) instead of stacking
   awkwardly under it. The wrapper tightly wraps the single field cell; the flag is
   out of flow (absolute), so the grid layout is unchanged when the flag is hidden. */
.technical-data-card .essential-field-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* The inner field cell fills the wrapper so the absolute flag aligns to the cell corner. */
.technical-data-card .essential-field-wrapper > .livelink-field {
    flex: 1 1 auto;
}

/* #144 — pad the cell's bottom-right so the value text never collides with the flag. */
.technical-data-card .essential-field-wrapper .mold-feedback-badge,
.technical-data-card .essential-field-wrapper .field-feedback-flag {
    position: absolute;
    bottom: 6px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--feedback-flag, #94a3b8);
    opacity: 0.4;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm, 4px);
    transition: opacity 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

/* Discreet at rest; revealed (and accent-colored) when the user hovers/focuses the cell
   or the flag itself. Always tabbable. */
.technical-data-card .essential-field-wrapper:hover .mold-feedback-badge,
.technical-data-card .essential-field-wrapper:focus-within .mold-feedback-badge,
.technical-data-card .essential-field-wrapper:hover .field-feedback-flag,
.technical-data-card .essential-field-wrapper:focus-within .field-feedback-flag,
.technical-data-card .essential-field-wrapper .field-feedback-flag:hover,
.technical-data-card .essential-field-wrapper .field-feedback-flag:focus-visible {
    opacity: 1;
    color: var(--feedback-flag-active, #d97706);
    transform: scale(1.08);
}

.technical-data-card .essential-field-wrapper .mold-feedback-badge:focus-visible,
.technical-data-card .essential-field-wrapper .field-feedback-flag:focus-visible {
    outline: 2px solid var(--medtronic-blue-interactive, #1010EB);
    outline-offset: 2px;
    opacity: 1;
}

.technical-data-card .field-feedback-flag__icon {
    font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
    .technical-data-card .essential-field-wrapper .mold-feedback-badge,
    .technical-data-card .essential-field-wrapper .field-feedback-flag {
        transition: none;
        transform: none;
    }
}

.technical-data-card .compact-label {
    font-size: var(--field-label-size);
    font-weight: var(--field-label-weight);
    color: var(--field-label-color);
    text-transform: var(--field-label-transform);
    letter-spacing: var(--field-label-spacing);
}

.technical-data-card .compact-value {
    font-size: var(--field-value-size);
    font-weight: var(--field-value-weight);
    color: var(--field-value-color);
}

/* ========== SECONDARY INFO ROW ========== */

.technical-data-card .secondary-info-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
    padding: 4px 0;
}

.technical-data-card .secondary-info-row .info-item {
    display: inline;
}

.technical-data-card .secondary-info-row .info-item strong {
    font-weight: 600;
    color: #6b7280;
}

.technical-data-card .secondary-info-row .info-separator {
    color: #d1d5db;
    margin: 0 2px;
}

/* ========== EMPTY STATE ========== */

.technical-data-card .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: #9ca3af;
}

.technical-data-card .empty-state .oi {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.technical-data-card .empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ========== LEGACY STYLES (kept for backwards compatibility) ========== */

.technical-data-card .essential-fields-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.technical-data-card .summary-grid {
    display: none; /* Replaced by secondary-info-row */
}

/* ========== DETAILED FIELDS SECTION ========== */

.technical-data-card .detailed-fields-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #e5e7eb;
}

.technical-data-card .show-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #06b6d4;
    background: transparent;
    border: 1px solid #06b6d4;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.technical-data-card .show-more-btn:hover {
    background-color: rgba(6, 182, 212, 0.08);
}

.technical-data-card .show-more-btn:focus-visible {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
}

.technical-data-card .show-more-btn.expanded {
    background-color: rgba(6, 182, 212, 0.08);
}

/* ========== DETAILED FIELDS GRID ========== */

.technical-data-card .detailed-fields-grid {
    margin-top: 16px;
}

.technical-data-card .field-category {
    margin-bottom: 16px;
}

.technical-data-card .field-category:last-child {
    margin-bottom: 0;
}

.technical-data-card .category-title {
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
}

.technical-data-card .category-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.technical-data-card .detailed-field-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0;
}

.technical-data-card .detailed-field-item .field-label {
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.technical-data-card .detailed-field-item .field-value {
    font-size: 12px;
    color: #374151;
}

/* ========== LAST REFRESHED ========== */

.technical-data-card .last-refreshed {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    color: #9ca3af;
}

.technical-data-card .last-refreshed .oi {
    font-size: 10px;
}

/* ========== COLLAPSED STATE ========== */

.technical-data-card.collapsed .card-body {
    display: none;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 992px) {
    .technical-data-card .compact-fields-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .technical-data-card .essential-fields-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .technical-data-card .compact-fields-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .technical-data-card .essential-fields-row {
        grid-template-columns: 1fr;
    }

    .technical-data-card .category-fields {
        grid-template-columns: 1fr;
    }

    .technical-data-card .header-content {
        flex-wrap: wrap;
        gap: 8px;
    }

    .technical-data-card .read-only-badge {
        order: 3;
        flex-basis: 100%;
    }

    .technical-data-card .secondary-info-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .technical-data-card .secondary-info-row .info-separator {
        display: none;
    }
}

@media (max-width: 576px) {
    .technical-data-card .card-header {
        padding: 8px 10px;
    }

    .technical-data-card .card-body {
        padding: 10px;
    }

    .technical-data-card .card-title {
        font-size: 13px;
    }

    .technical-data-card .compact-fields-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

/* ========== ACCESSIBILITY: REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
    .technical-data-card {
        transition: none;
    }

    .technical-data-card .card-header,
    .technical-data-card .expand-toggle,
    .technical-data-card .show-more-btn {
        transition: none;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .technical-data-card {
        border: 1px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .technical-data-card .expand-toggle,
    .technical-data-card .show-more-btn {
        display: none;
    }

    .technical-data-card .detailed-fields-grid {
        display: block !important;
    }
}
