/* Maintenance Card Styles */

.vehicle-maintenance-section {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 8px;
    box-sizing: border-box;
}

/* Vehicle Health Section - Allow full expansion on desktop */
.vehicle-health-section-new {
    max-height: 2000px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Maintenance Trigger (Manual Analysis Button) */
.maintenance-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1rem;
    gap: 0.75rem;
}

.maintenance-trigger-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    animation: pulse-gentle 2s ease-in-out infinite;
}

@keyframes pulse-gentle {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

.maintenance-trigger-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.maintenance-trigger-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.maintenance-trigger-btn {
    margin-top: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(168, 85, 247, 0.95));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.maintenance-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, rgba(59, 130, 246, 1), rgba(168, 85, 247, 1));
}

.maintenance-trigger-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.maintenance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.maintenance-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.maintenance-refresh-btn {
    background: transparent;
    border: 1px solid rgba(100, 116, 139, 0.3);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.maintenance-refresh-btn:hover {
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--color-primary);
}

.maintenance-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Health Score */
.health-score-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.health-score-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    order: 2;
}

.health-score-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.health-score-label {
    font-size: 0.625rem;
    opacity: 0.8;
    margin-top: 0.125rem;
}

.health-score-details {
    flex: 1;
    font-size: 0.75rem;
    order: 1;
}

.health-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
    padding: 0.375rem 0.5rem;
    background: rgba(17, 24, 39, 0.5);
    border-radius: 6px;
}

.health-score-item:last-child {
    margin-bottom: 0;
}

.health-score-item-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.health-score-item-value {
    font-weight: 700;
    font-size: 0.9rem;
}

/* Next Service Alert */
.next-service-alert {
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    border: 1px solid;
}

.next-service-alert.overdue {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.next-service-alert.urgent {
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.3);
}

.next-service-alert.soon {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.next-service-alert.future {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.next-service-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.next-service-type {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.next-service-miles {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Upcoming Maintenance */
.upcoming-maintenance {
    margin-bottom: 0.75rem;
}

.upcoming-maintenance-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.maintenance-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.maintenance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(51, 65, 85, 0.3);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
}

.maintenance-item-info {
    flex: 1;
}

.maintenance-item-service {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.maintenance-item-miles {
    color: var(--text-secondary);
    font-size: 0.6875rem;
}

.maintenance-item-cost {
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* Critical Items */
.critical-items {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
}

.critical-items-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #ef4444;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.critical-item {
    font-size: 0.75rem;
    color: var(--text-primary);
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.critical-item:last-child {
    border-bottom: none;
}

.critical-item-service {
    font-weight: 700;
    color: #ef4444;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.critical-item-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.critical-item-consequence {
    font-size: 0.75rem;
    color: #f59e0b;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
}

.critical-item-cost {
    font-size: 0.875rem;
    font-weight: 600;
    color: #22c55e;
    margin-top: 0.125rem;
}

/* Maintenance Summary */
.maintenance-summary {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    margin-top: 1rem;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.maintenance-summary-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.maintenance-summary-text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Expandable Sections */
.maintenance-section {
    margin-top: 1.25rem;
}

.maintenance-section-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    box-sizing: border-box;
}

.maintenance-section-header:hover {
    background: rgba(17, 24, 39, 0.95);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.section-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 0.5rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-total-cost {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-green);
}

.section-toggle-icon {
    display: flex;
    align-items: center;
    color: var(--accent-blue);
    transition: transform 0.3s ease;
}

.section-toggle-icon svg {
    width: 20px;
    height: 20px;
}

.maintenance-section-content {
    max-height: 2000px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
    padding: 1rem 0 0 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.maintenance-section-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
}

/* Detail Items */
.maintenance-detail-item {
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.maintenance-detail-item:last-child {
    margin-bottom: 0;
}

.maintenance-detail-item:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(15, 23, 42, 0.85);
}

.maintenance-detail-item.critical-level {
    border-left: 4px solid #ef4444;
}

.maintenance-detail-item.upcoming-level {
    border-left: 4px solid #f59e0b;
}

.maintenance-detail-item.future-level {
    border-left: 4px solid #3b82f6;
}

.detail-item-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.detail-item-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.detail-item-title {
    flex: 1;
    min-width: 0;
}

.detail-item-service {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.detail-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.urgency-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.urgency-badge.urgency-high {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.urgency-badge.urgency-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.urgency-badge.urgency-low {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(226, 232, 240, 0.9);
    text-transform: capitalize;
}

.detail-item-miles {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.detail-item-cost {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-green);
    flex-shrink: 0;
}

.detail-item-section {
    margin-top: 0.875rem;
    padding: 0.875rem;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.detail-item-section.consequence-section {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.detail-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
}

.consequence-section .detail-section-label {
    color: #f59e0b;
}

.detail-section-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Risk Factors */
.risk-factor-item {
    display: flex;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-left: 3px solid #ef4444;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.risk-factor-item:last-child {
    margin-bottom: 0;
}

.risk-factor-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #ef4444;
    flex-shrink: 0;
}

.risk-factor-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Cost Summary */
.cost-summary {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.cost-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cost-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.cost-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.cost-value.critical-cost {
    color: #ef4444;
}

.cost-value.annual-cost {
    color: var(--accent-green);
}

/* Cost Estimate */
.cost-estimate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.cost-estimate-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cost-estimate-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* Maintenance Actions */
.maintenance-actions {
    display: flex;
    gap: 0.5rem;
}

.maintenance-action-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.maintenance-action-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.maintenance-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading State */
.maintenance-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 0.75rem;
}

.maintenance-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.maintenance-loading-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error State */
.maintenance-error {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    text-align: center;
}

.maintenance-error-text {
    font-size: 0.75rem;
    color: #ef4444;
    margin-bottom: 0.5rem;
}

.maintenance-error-retry {
    font-size: 0.75rem;
    color: var(--color-primary);
    background: transparent;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.maintenance-error-retry:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Update Mileage Modal */
.update-mileage-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.update-mileage-modal.active {
    display: flex;
}

.update-mileage-content {
    background: var(--bg-primary, #1e293b);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.update-mileage-header {
    margin-bottom: 1.5rem;
}

.update-mileage-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.update-mileage-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.update-mileage-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.update-mileage-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.update-mileage-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.update-mileage-input {
    padding: 0.75rem;
    border: 1px solid rgba(100, 116, 139, 0.3);
    background: rgba(30, 41, 59, 0.4);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.update-mileage-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(30, 41, 59, 0.6);
}

.update-mileage-error {
    font-size: 0.75rem;
    color: #ef4444;
    display: none;
}

.update-mileage-error.active {
    display: block;
}

.update-mileage-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.update-mileage-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
}

.update-mileage-btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.update-mileage-btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover, #2563eb);
}

.update-mileage-btn-secondary {
    background: transparent;
    border-color: rgba(100, 116, 139, 0.3);
    color: var(--text-secondary);
}

.update-mileage-btn-secondary:hover {
    border-color: rgba(100, 116, 139, 0.5);
    background: rgba(100, 116, 139, 0.1);
}

.update-mileage-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .vehicle-maintenance-section {
        padding: 0.75rem;
    }

    .health-score-circle {
        width: 50px;
        height: 50px;
        border-width: 2px;
    }

    .health-score-value {
        font-size: 1.25rem;
    }

    .health-score-details {
        font-size: 0.6875rem;
    }

    .maintenance-actions {
        flex-direction: column;
    }

    .update-mileage-content {
        padding: 1.5rem;
    }
}
