/* ==========================================================================
   Field Grid CSS Custom Properties
   Sprint S5: Field Unification - Story 28.21

   Shared design tokens for TechnicalDataCard, ProjectTechnicalSheet,
   EditableCompactField, and DynamicFieldsRenderer components.

   Usage: Import in _Layout.cshtml BEFORE component-specific CSS files.
   ========================================================================== */

:root {
    /* ========== GRID LAYOUT ========== */
    --field-grid-columns: 4;
    --field-grid-gap: 12px;
    --field-grid-row-gap: 8px;

    /* Column Spans for FieldSize enum */
    --field-span-small: 1;   /* FieldSize.Small */
    --field-span-medium: 2;  /* FieldSize.Medium */
    --field-span-large: 3;   /* FieldSize.Large */
    --field-span-full: 4;    /* FieldSize.Full */

    /* ========== SPACING ========== */
    --field-padding: 8px 12px;
    --field-padding-compact: 6px 8px;
    --field-margin-bottom: 4px;

    /* ========== BORDERS ========== */
    --field-border-radius: 4px;
    --field-border-radius-lg: 6px;
    --field-border-width: 1px;
    --field-border-color: #e5e7eb;
    --field-border-livelink-width: 4px;

    /* ========== BACKGROUNDS ========== */
    --field-bg-editable: #ffffff;
    --field-bg-readonly: #f9fafb;
    --field-bg-hover: #f3f4f6;
    --field-bg-focus: #ffffff;
    --field-bg-disabled: #f3f4f6;

    /* ========== TYPOGRAPHY - LABELS ========== */
    --field-label-size: 11px;
    --field-label-weight: 500;
    --field-label-color: #6b7280;
    --field-label-spacing: 0;
    --field-label-transform: none;  /* Removed uppercase for cleaner look */

    /* ========== TYPOGRAPHY - VALUES ========== */
    --field-value-size: 14px;
    --field-value-weight: 600;
    --field-value-color: #111827;
    --field-value-placeholder: #9ca3af;

    /* ========== TYPOGRAPHY - INPUT ========== */
    --field-input-size: 14px;
    --field-input-weight: 400;
    --field-input-color: #374151;
    --field-input-border: 1px solid #d1d5db;
    --field-input-border-focus: 1px solid #3b82f6;

    /* ========== LIVELINK COLORS ========== */
    --color-livelink: #0ea5e9;
    --color-livelink-bg: #e0f2fe;
    --color-livelink-border: #0ea5e9;
    --color-livelink-hover: #0284c7;

    /* ========== STATUS COLORS ========== */
    --color-status-good: #22c55e;
    --color-status-good-bg: #dcfce7;
    --color-status-fair: #eab308;
    --color-status-fair-bg: #fef9c3;
    --color-status-warning: #f59e0b;
    --color-status-warning-bg: #fef3c7;
    --color-status-poor: #ef4444;
    --color-status-poor-bg: #fee2e2;
    --color-status-danger: #dc2626;
    --color-status-danger-bg: #fee2e2;
    --color-status-neutral: #6b7280;
    --color-status-neutral-bg: #f3f4f6;

    /* ========== VALIDATION COLORS ========== */
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;
    --color-error-border: #fca5a5;
    --color-success: #22c55e;
    --color-success-bg: #f0fdf4;

    /* ========== TOOLTIP ========== */
    --tooltip-bg: #1f2937;
    --tooltip-text: #ffffff;
    --tooltip-padding: 6px 10px;
    --tooltip-max-width: 250px;
    --tooltip-font-size: 12px;
    --tooltip-border-radius: 4px;
    --tooltip-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* ========== SHADOWS ========== */
    --field-shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.1);
    --field-shadow-hover: 0 1px 2px rgba(0, 0, 0, 0.05);

    /* ========== TRANSITIONS ========== */
    --field-transition: all 0.15s ease;
    --field-transition-fast: all 0.1s ease;
}

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

/* Tablet (1024px and below) - 2 columns */
@media (max-width: 1024px) {
    :root {
        --field-grid-columns: 2;
        --field-span-large: 2;
        --field-span-full: 2;
    }
}

/* Mobile (640px and below) - 1 column */
@media (max-width: 640px) {
    :root {
        --field-grid-columns: 1;
        --field-span-small: 1;
        --field-span-medium: 1;
        --field-span-large: 1;
        --field-span-full: 1;
        --field-grid-gap: 8px;
        --field-padding: 6px 10px;
    }
}

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

/* Base field grid container */
.field-grid {
    display: grid;
    grid-template-columns: repeat(var(--field-grid-columns), 1fr);
    gap: var(--field-grid-gap);
    row-gap: var(--field-grid-row-gap);
}

/* Field size spans */
.field-span-small {
    grid-column: span var(--field-span-small);
}

.field-span-medium {
    grid-column: span var(--field-span-medium);
}

.field-span-large {
    grid-column: span var(--field-span-large);
}

.field-span-full {
    grid-column: span var(--field-span-full);
}

/* MULTILINE_TEXT fields always span full width for better UX */
.editable-compact-field:has(.field-multiline-text) {
    grid-column: span var(--field-span-full);
}

/* ========== STATUS INDICATOR CLASSES ========== */

.status-good {
    color: var(--color-status-good);
}

.status-good-bg {
    background-color: var(--color-status-good-bg);
    color: var(--color-status-good);
}

.status-fair,
.status-warning {
    color: var(--color-status-warning);
}

.status-fair-bg,
.status-warning-bg {
    background-color: var(--color-status-warning-bg);
    color: var(--color-status-warning);
}

.status-poor,
.status-danger {
    color: var(--color-status-danger);
}

.status-poor-bg,
.status-danger-bg {
    background-color: var(--color-status-danger-bg);
    color: var(--color-status-danger);
}

.status-neutral {
    color: var(--color-status-neutral);
}

.status-neutral-bg {
    background-color: var(--color-status-neutral-bg);
    color: var(--color-status-neutral);
}

/* ========== LIVELINK INDICATOR ========== */

.livelink-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-livelink);
    background-color: var(--color-livelink-bg);
    border-radius: 100px;
}

.livelink-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: var(--color-livelink);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ========== TOOLTIP BASE STYLES ========== */

.field-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 10px;
    color: var(--field-label-color);
    cursor: help;
}

.field-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--tooltip-padding);
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    font-size: var(--tooltip-font-size);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
    max-width: var(--tooltip-max-width);
    border-radius: var(--tooltip-border-radius);
    box-shadow: var(--tooltip-shadow);
    z-index: 1000;
    margin-bottom: 4px;
}

/* ========== REQUIRED INDICATOR ========== */

.field-required {
    color: var(--color-error);
    margin-left: 2px;
}

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

@media (prefers-reduced-motion: reduce) {
    :root {
        --field-transition: none;
        --field-transition-fast: none;
    }

    .livelink-indicator::before {
        animation: none;
    }
}

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

@media print {
    .field-grid {
        display: block;
    }

    .field-span-small,
    .field-span-medium,
    .field-span-large,
    .field-span-full {
        grid-column: auto;
        margin-bottom: 8px;
    }

    .livelink-indicator::before {
        animation: none;
    }
}
