/**
 * ENNU Template System Styles
 * Medical-grade responsive design with accessibility
 * 
 * @package ENNU_Life_Assessments
 * @version 1.0.0
 * @since 99.7.0
 */

/* ==========================================================================
   Base Template Styles
   ========================================================================== */

.ennu-template-container {
    position: relative;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.ennu-template-container * {
    box-sizing: border-box;
}

/* Loading States */
.ennu-template-container.loading {
    min-height: 200px;
    position: relative;
}

.template-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

.template-loader:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4FACFE;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.template-error {
    padding: 20px;
    background: #FEE2E2;
    border: 1px solid #EF4444;
    border-radius: 8px;
    color: #991B1B;
    text-align: center;
}

/* ==========================================================================
   Chart Containers
   ========================================================================== */

.ennu-chart-container {
    position: relative;
    width: 100%;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.ennu-chart-container canvas {
    max-height: 400px;
}

.ennu-chart-wrapper {
    margin-bottom: 30px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #E5E7EB;
}

.chart-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1F2937;
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.chart-timeframe {
    padding: 8px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.chart-timeframe:focus {
    outline: none;
    border-color: #4FACFE;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.chart-details {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #E5E7EB;
}

/* ==========================================================================
   Dashboard Components
   ========================================================================== */

/* Score Overview */
.ennu-score-overview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 30px;
    border-radius: 16px;
    margin-bottom: 30px;
}

.engine-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.engine-score-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease, background 0.3s ease;
}

.engine-score-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
}

.score-circle {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
}

.score-svg {
    width: 100%;
    height: 100%;
}

.score-progress {
    transition: stroke-dasharray 1s ease;
}

.score-text {
    font-size: 28px;
    font-weight: bold;
    fill: #fff;
}

.engine-score-card h4 {
    margin: 0 0 5px;
    font-size: 16px;
    font-weight: 600;
}

.score-label {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.overall-score {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.overall-score h3 {
    margin: 0 0 15px;
    font-size: 20px;
    font-weight: 600;
}

.overall-score-display {
    font-size: 48px;
    font-weight: bold;
}

.score-suffix {
    font-size: 24px;
    opacity: 0.8;
}

/* Care Team */
.ennu-care-team {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.ennu-care-team h3 {
    margin: 0 0 20px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1F2937;
}

.care-team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.team-member-card {
    display: flex;
    padding: 20px;
    background: #F9FAFB;
    border-radius: 10px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.team-member-card:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.member-photo {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    margin-right: 20px;
}

.member-photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.member-info {
    flex-grow: 1;
}

.member-info h4 {
    margin: 0 0 5px;
    font-size: 18px;
    font-weight: 600;
    color: #1F2937;
}

.member-role {
    margin: 0 0 5px;
    font-size: 14px;
    color: #6B7280;
    font-weight: 500;
}

.member-specialization {
    margin: 0 0 15px;
    font-size: 13px;
    color: #9CA3AF;
}

.member-actions {
    display: flex;
    gap: 10px;
}

.member-actions a {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s ease;
}

.member-actions a:hover {
    background: #4FACFE;
    border-color: #4FACFE;
    color: #fff;
}

.member-actions .dashicons {
    font-size: 16px;
    margin-right: 5px;
}

/* Progress Tracker */
.ennu-progress-tracker {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.ennu-progress-tracker h3 {
    margin: 0 0 25px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1F2937;
}

.progress-milestones {
    margin-bottom: 30px;
}

.milestone {
    display: flex;
    padding: 15px;
    margin-bottom: 15px;
    background: #F9FAFB;
    border-radius: 10px;
    border-left: 4px solid #E5E7EB;
    transition: all 0.3s ease;
}

.milestone.completed {
    border-left-color: #10B981;
    background: #F0FDF4;
}

.milestone:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.milestone-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    font-size: 20px;
    color: #9CA3AF;
}

.milestone.completed .milestone-icon {
    background: #10B981;
    color: #fff;
}

.milestone-content {
    flex-grow: 1;
}

.milestone-content h4 {
    margin: 0 0 5px;
    font-size: 16px;
    font-weight: 600;
    color: #1F2937;
}

.milestone-content p {
    margin: 0 0 8px;
    font-size: 14px;
    color: #6B7280;
}

.milestone-date {
    font-size: 12px;
    color: #9CA3AF;
}

.pillar-progress {
    margin-top: 25px;
}

.pillar-progress-item {
    margin-bottom: 20px;
}

.pillar-progress-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.progress-bar {
    position: relative;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #4FACFE 0%, #00F2FE 100%);
    border-radius: 4px;
    transition: width 1s ease;
}

.progress-value {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
}

/* ==========================================================================
   Dashboard Tabs
   ========================================================================== */

.dashboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #E5E7EB;
    overflow-x: auto;
}

.dashboard-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6B7280;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.dashboard-tab:hover {
    color: #374151;
}

.dashboard-tab.active {
    color: #4FACFE;
    border-bottom-color: #4FACFE;
}

.dashboard-tab-content {
    display: none;
}

.dashboard-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Biomarker Visualizations
   ========================================================================== */

.ennu-biomarker-chart-wrapper {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.biomarker-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.biomarker-detail-card {
    padding: 15px;
    background: #F9FAFB;
    border-radius: 8px;
    border-left: 3px solid #4FACFE;
}

.biomarker-detail-card h5 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.biomarker-value {
    font-size: 24px;
    font-weight: bold;
    color: #1F2937;
}

.biomarker-unit {
    font-size: 14px;
    color: #6B7280;
    margin-left: 5px;
}

.biomarker-trend {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    color: #6B7280;
}

.biomarker-trend.positive {
    color: #10B981;
}

.biomarker-trend.negative {
    color: #EF4444;
}

/* ==========================================================================
   Mobile Responsive Design
   ========================================================================== */

/* Mobile Styles (< 576px) */
@media (max-width: 575px) {
    .ennu-template-container {
        padding: 15px;
    }
    
    .engine-scores {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .score-circle {
        width: 80px;
        height: 80px;
    }
    
    .score-text {
        font-size: 24px;
    }
    
    .overall-score-display {
        font-size: 36px;
    }
    
    .care-team-grid {
        grid-template-columns: 1fr;
    }
    
    .team-member-card {
        flex-direction: column;
        text-align: center;
    }
    
    .member-photo {
        margin: 0 auto 15px;
    }
    
    .dashboard-tabs {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-tab {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-controls {
        margin-top: 10px;
        width: 100%;
    }
    
    .chart-timeframe {
        flex-grow: 1;
    }
    
    .ennu-chart-container {
        padding: 15px;
    }
    
    .ennu-chart-container canvas {
        max-height: 250px;
    }
}

/* Tablet Styles (576px - 768px) */
@media (min-width: 576px) and (max-width: 767px) {
    .engine-scores {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .care-team-grid {
        grid-template-columns: 1fr;
    }
}

/* Small Desktop (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .engine-scores {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .care-team-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/* Focus Styles */
*:focus {
    outline: 2px solid #4FACFE;
    outline-offset: 2px;
}

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4FACFE;
    color: #fff;
    padding: 8px 12px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .ennu-chart-container,
    .team-member-card,
    .milestone {
        border: 2px solid currentColor;
    }
    
    .progress-fill {
        background: currentColor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ennu-template-container {
        max-width: none;
        padding: 0;
    }
    
    .chart-controls,
    .member-actions,
    .dashboard-tabs {
        display: none;
    }
    
    .ennu-chart-container,
    .ennu-care-team,
    .ennu-progress-tracker {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .ennu-score-overview {
        background: none;
        color: #000;
        border: 1px solid #000;
    }
    
    .score-text {
        fill: #000;
    }
}

/* ==========================================================================
   Component States
   ========================================================================== */

.dashboard-component.refreshing {
    opacity: 0.6;
    pointer-events: none;
}

.component-refresh.spinning {
    animation: spin 1s linear infinite;
}

.template-type-assessment_form {
    max-width: 800px;
}

.template-type-assessment_result {
    max-width: 1200px;
}

.template-type-email_template {
    max-width: 600px;
}

/* Table Responsiveness */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.ennu-table-responsive {
    min-width: 100%;
    border-collapse: collapse;
}

.ennu-table-responsive th,
.ennu-table-responsive td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

.ennu-table-responsive th {
    background: #F9FAFB;
    font-weight: 600;
    color: #374151;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.p-10 { padding: 10px; }
.p-20 { padding: 20px; }
.p-30 { padding: 30px; }