/* File: app/static/css/main.css - REDESIGNED COLOR SYSTEM */

/* 
==================================================================
REDESIGNED COLOR SYSTEM - SEMANTIC AND PURPOSEFUL
==================================================================
Red = Danger, Failure, Critical Issues ONLY
Blue = Primary actions, navigation, brand
Orange = Warnings, attention needed
Green = Success, pass, good status
==================================================================
*/

:root {
    /* Primary Brand Colors - BLUE BASED */
    --primary-blue: #1e3a8a;        /* Deep professional blue */
    --primary-blue-light: #3b82f6;  /* Lighter blue for hover */
    --primary-blue-dark: #1e40af;   /* Darker blue for active states */
    --accent-blue: #0ea5e9;         /* Bright accent blue */
    
    /* Background & Neutral Colors */
    --clean-white: #ffffff;
    --background-light: #f8fafc;
    --background-card: #ffffff;
    --text-dark: #1e293b;
    --text-medium: #64748b;
    --text-light: #cbd5e1;
    --border-light: #e2e8f0;
    
    /* Semantic Status Colors */
    --success-green: #10b981;       /* Pass, success, good */
    --warning-orange: #f59e0b;      /* Warning, attention needed */
    --danger-red: #dc2626;          /* ONLY for failures, errors, danger */
    --info-blue: #3b82f6;           /* Informational, neutral status */
    --conditional-amber: #f59e0b;   /* Conditional pass, needs review */
    
    /* Shadows */
    --shadow-light: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-medium: 0 4px 12px rgba(15, 23, 42, 0.12);
    --shadow-strong: 0 8px 24px rgba(15, 23, 42, 0.15);
}

/* ===== BUTTONS - BLUE PRIMARY ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    text-decoration: none;
    margin: 0.25rem;
}

/* Primary action buttons - BLUE */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--clean-white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--primary-blue) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-light);
}

/* Secondary buttons - neutral */
.btn-secondary {
    background: var(--background-card);
    color: var(--text-dark);
    border: 2px solid var(--border-light);
    box-shadow: var(--shadow-light);
}

.btn-secondary:hover {
    background: var(--background-light);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
}

/* Success button - GREEN (for completing, passing) */
.btn-success {
    background: linear-gradient(135deg, var(--success-green) 0%, #059669 100%);
    color: var(--clean-white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
}

.btn-success:hover {
    background: linear-gradient(135deg, #10b981 0%, var(--success-green) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Danger button - RED (ONLY for delete, fail, critical actions) */
.btn-danger {
    background: linear-gradient(135deg, var(--danger-red) 0%, #b91c1c 100%);
    color: var(--clean-white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, var(--danger-red) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Warning button - ORANGE */
.btn-warning {
    background: linear-gradient(135deg, var(--warning-orange) 0%, #d97706 100%);
    color: var(--clean-white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #fbbf24 0%, var(--warning-orange) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Info button - BLUE (for informational, helpful actions like "Call monitoring company") */
.btn-info {
    background: linear-gradient(135deg, var(--info-blue) 0%, var(--primary-blue) 100%);
    color: var(--clean-white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
}

.btn-info:hover {
    background: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--info-blue) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* Icon buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
}

.btn-icon.btn-success {
    background: var(--success-green);
}

.btn-icon.btn-danger {
    background: var(--danger-red);
}

/* ===== HEADER - BLUE THEME ===== */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--clean-white);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-medium);
}

/* ===== NAVIGATION TABS ===== */
.nav-tab {
    flex: 1;
    padding: 1rem;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-medium);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.nav-tab:hover {
    color: var(--primary-blue);
    background: var(--background-light);
}

.nav-tab.active {
    color: var(--primary-blue);
    border-bottom: 3px solid var(--primary-blue);
    background: var(--background-card);
    font-weight: 600;
}

/* ===== STATUS BADGES - SEMANTIC COLORS ===== */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid transparent;
}

/* Draft status - neutral gray */
.status-draft {
    background: rgba(100, 116, 139, 0.15);
    color: #475569;
    border-color: rgba(100, 116, 139, 0.3);
}

/* Completed status - blue (work done) */
.status-completed {
    background: rgba(59, 130, 246, 0.15);
    color: #1e40af;
    border-color: rgba(59, 130, 246, 0.3);
}

/* Submitted status - info blue */
.status-submitted {
    background: rgba(14, 165, 233, 0.15);
    color: #0c4a6e;
    border-color: rgba(14, 165, 233, 0.3);
}

/* PASS - GREEN */
.status-pass {
    background: rgba(16, 185, 129, 0.15);
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.3);
}

/* FAIL - RED (appropriate use) */
.status-fail {
    background: rgba(220, 38, 38, 0.15);
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.3);
}

/* Conditional - ORANGE */
.status-conditional {
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.3);
}

/* ===== ALERTS - SEMANTIC ===== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 500;
    border: 2px solid transparent;
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    animation: slideIn 0.3s ease;
}

.alert::before {
    margin-right: 0.75rem;
    font-weight: bold;
    font-size: 1.2em;
}

.alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(5, 150, 105, 0.9) 100%);
    color: var(--clean-white);
    border-color: var(--success-green);
}

.alert-success::before {
    content: "✓";
}

.alert-error {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(185, 28, 28, 0.9) 100%);
    color: var(--clean-white);
    border-color: var(--danger-red);
}

.alert-error::before {
    content: "⚠";
}

.alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95) 0%, rgba(217, 119, 6, 0.9) 100%);
    color: var(--clean-white);
    border-color: var(--warning-orange);
}

.alert-warning::before {
    content: "⚡";
}

.alert-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95) 0%, rgba(37, 99, 235, 0.9) 100%);
    color: var(--clean-white);
    border-color: var(--info-blue);
}

.alert-info::before {
    content: "ℹ";
}

/* Flash Messages - Add this to app/static/css/main.css */

.flash-messages {
    margin: 20px 0;
}

.flash-message {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.flash-message.success {
    background-color: #f0fff4;
    border-left-color: #22c55e;
    color: #15803d;
}

.flash-message.error {
    background-color: #fef2f2;
    border-left-color: #ef4444;
    color: #dc2626;
}

.flash-message.warning {
    background-color: #fffbeb;
    border-left-color: #f59e0b;
    color: #d97706;
}

.flash-message.info {
    background-color: #eff6ff;
    border-left-color: #3b82f6;
    color: #2563eb;
}

.flash-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.flash-text {
    flex: 1;
}

/* Override the old alert styles */
.alert {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background-color: #f0fff4;
    border-left-color: #22c55e;
    color: #15803d;
}

.alert-error {
    background-color: #fef2f2;
    border-left-color: #ef4444;
    color: #dc2626;
}

.alert-warning {
    background-color: #fffbeb;
    border-left-color: #f59e0b;
    color: #d97706;
}

/* ===== FORM INPUTS ===== */
.form-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: var(--background-card);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* ===== LINKS ===== */
a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-blue-light);
    text-decoration: underline;
}

/* ===== CARDS - Subtle branding ===== */
.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary-blue);
}

/* ===== LIST ITEMS ===== */
.list-item:hover {
    background: var(--background-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
    border-color: var(--primary-blue);
}

.list-item-title {
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 0.25rem;
}

/* ===== PROGRESS BAR - BLUE ===== */
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
    transition: width 0.4s ease;
    border-radius: 3px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShimmer 2s infinite;
}

/* ===== VALIDATION STATES - CLEAR SEMANTIC MEANING ===== */
.field-completed {
    border-left: 4px solid var(--success-green);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.03) 0%, transparent 100%);
}

.field-error {
    border-left: 4px solid var(--danger-red);
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.05) 0%, transparent 100%);
}

.field-warning {
    border-left: 4px solid var(--warning-orange);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.03) 0%, transparent 100%);
}

/* ===== PRESSURE READING VALIDATION ===== */
.pressure-reading-good {
    background: rgba(16, 185, 129, 0.15);
    color: #065f46;
    border: 2px solid var(--success-green);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
}

.pressure-reading-fail {
    background: rgba(220, 38, 38, 0.15);
    color: #991b1b;
    border: 2px solid var(--danger-red);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: bold;
    animation: failPulse 0.5s ease;
}

.pressure-reading-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
    border: 2px solid var(--warning-orange);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
}

/* ===== RADIO BUTTONS - COMPACT YES/NO/NA LAYOUT =====*/
/* ✅ FIXED: Compatible with inspections.css compact layout */

.radio-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;  /* ✅ Slightly shorter */
    border: 2px solid var(--border-light);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    background: var(--background-card);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
    color: var(--text-dark);
    min-height: 44px; /* ✅ Reduced from 48px for compact layout */
}

/* Hover state - blue hint */
.radio-option:hover:not(.selected) {
    border-color: var(--primary-blue);
    background: rgba(30, 58, 138, 0.05);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

/* ✅ FIXED: Removed checkmark to prevent conflict with Issue 3 fix */
/* DISABLED - Conflicts with no-checkmark requirement
.radio-option.selected::after {
    content: "✓"";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--clean-white);
    opacity: 0.9;
}
*/

/* ✅ FIXED: Default selected state (BLUE for non Yes/No/NA questions) */
.radio-option.selected {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: var(--clean-white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
    font-weight: 600;
}

/* ✅ NEW: Color-coded selections for Yes/No/NA */
/* Yes button - GREEN when selected */
.radio-option:nth-child(1).selected {
    background: var(--success-green);
    border-color: var(--success-green);
}

/* No button - RED when selected */
.radio-option:nth-child(2).selected {
    background: var(--danger-red);
    border-color: var(--danger-red);
}

/* No button - YELLOW/ORANGE when it's a recommendation instead of deficiency */
.radio-option:nth-child(2).selected.recommendation {
    background: var(--warning-orange);
    border-color: var(--warning-orange);
}

/* NA button - GRAY when selected */
.radio-option:nth-child(3).selected {
    background: var(--text-medium);
    border-color: var(--text-medium);
}

/* Action options (like Replaced/Tested) - BLUE when selected */
/* Override nth-child coloring for action options - these are informational, not pass/fail */
.radio-option.action-option.selected,
.radio-option:nth-child(1).action-option.selected,
.radio-option:nth-child(2).action-option.selected {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: var(--clean-white);
}

/* ✅ FIXED: Radio group - GRID LAYOUT for compact Yes/No/NA */
.radio-group {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr 1fr;  /* ✅ Side by side for Yes/No */
    grid-template-rows: auto auto;
    margin-top: 0.5rem;
}

/* ✅ NEW: Third option (NA) spans full width on second row */
.radio-group > .radio-option:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 2;
}

/* ✅ FIXED: NA button shorter height */
.radio-group > .radio-option:nth-child(3) {
    padding: 0.5rem 1rem;  /* Shorter than Yes/No */
    font-size: 0.9rem;
}

/* For longer lists (4+ options), use flex column */
.radio-group:has(.radio-option:nth-child(4)) {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
}

.radio-group:has(.radio-option:nth-child(4)) .radio-option {
    width: 100%;
}

/* ===== ACCESSIBILITY ===== */
.radio-option:focus {
    outline: 3px solid rgba(30, 58, 138, 0.3);
    outline-offset: 2px;
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .radio-option {
        border-width: 3px;
    }
    
    .radio-option.selected {
        border-width: 4px;
        font-weight: bold;
    }
}

/* Yes/No/N/A style options - use compact layout */
.radio-group.simple-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.radio-group.simple-choice .radio-option {
    min-width: auto;
}

/* Pass/Fail - horizontal */
.radio-group.pass-fail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* Long descriptive options - FORCE vertical */
.radio-group.descriptive {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
}

.radio-group.descriptive .radio-option {
    text-align: left;
    padding: 1rem 1.5rem;
    width: 100%;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .btn {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .navigation-buttons {
        padding: 0.75rem;
    }
}

/* ✅ FIXED: Keep compact layout on mobile, just adjust sizing */
@media (max-width: 768px) {
    .radio-group {
        gap: 0.4rem;  /* Slightly smaller gap */
    }
    
    .radio-option {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 40px;
    }
    
    .radio-group > .radio-option:nth-child(3) {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
    
    /* For 5+ options on mobile, can stack if needed */
    .radio-group:has(.radio-option:nth-child(5)) {
        display: flex;
        flex-direction: column;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes failPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== PRINT STYLES ===== */
@media print {
    .btn-primary,
    .btn-secondary {
        border: 2px solid #000 !important;
        background: none !important;
        color: #000 !important;
    }
    
    .status-fail,
    .pressure-reading-fail {
        border: 3px solid #000 !important;
        background: none !important;
        font-weight: bold !important;
    }
}

@media print {
    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .radio-option.selected {
        border: 3px solid #000 !important;
        background: #000 !important;
        color: #fff !important;
        font-weight: bold;
    }
    
    .radio-option:not(.selected) {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}