/* Fleet Threshold Report System - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    overflow: hidden;
}

.header-content {
    padding: 30px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.title {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.title .icon {
    width: 32px;
    height: 32px;
}

.header-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 2px dashed var(--gray-300);
    transition: all 0.3s ease;
}

.upload-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--primary-color);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5;
}

.upload-card h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--gray-800);
}

.upload-card p {
    color: var(--gray-600);
    margin-bottom: 20px;
}

.upload-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.upload-btn:hover {
    background: var(--primary-hover);
}

.file-name {
    margin-top: 15px;
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
}

/* Loading Indicator */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-container p {
    color: var(--gray-600);
    font-size: 16px;
}

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger-color);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* Summary Section */
.summary-section {
    margin-bottom: 30px;
}

.summary-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--gray-800);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.summary-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.summary-card.passed::before {
    background: var(--success-color);
}

.summary-card.failed::before {
    background: var(--danger-color);
}

.summary-card.total::before {
    background: var(--primary-color);
}

.summary-card.rate::before {
    background: var(--warning-color);
}

.card-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.summary-card.passed .card-value {
    color: var(--success-color);
}

.summary-card.failed .card-value {
    color: var(--danger-color);
}

.summary-card.total .card-value {
    color: var(--primary-color);
}

.summary-card.rate .card-value {
    color: var(--warning-color);
}

.card-label {
    font-size: 14px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.card-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    opacity: 0.3;
}

/* Controls Section */
.controls-section {
    margin-bottom: 20px;
}

.controls-wrapper {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.filter-info {
    color: var(--gray-600);
    font-size: 14px;
}

.export-controls {
    display: flex;
    gap: 12px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Table Section */
.table-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    padding: 0;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

.header-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 8px;
}

.header-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.header-label:hover {
    color: var(--primary-color);
}

.sort-indicator {
    font-size: 12px;
    color: var(--primary-color);
}

.filter-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.filter-btn:hover {
    background: var(--gray-200);
}

.filter-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--gray-500);
    stroke-width: 2;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.status-passed {
    display: inline-block;
    padding: 4px 12px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 12px;
    font-weight: 500;
    font-size: 13px;
}

.status-failed {
    display: inline-block;
    padding: 4px 12px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 12px;
    font-weight: 500;
    font-size: 13px;
}

.no-data {
    text-align: center;
    padding: 40px !important;
    color: var(--gray-500);
    font-style: italic;
}

/* Filter Modal */
.filter-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.filter-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.filter-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: var(--gray-100);
}

.filter-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.filter-search {
    margin-bottom: 15px;
}

.filter-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
}

.filter-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-options {
    max-height: 300px;
    overflow-y: auto;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
    user-select: none;
}

.filter-option:hover {
    background: var(--gray-50);
    margin: 0 -8px;
    padding: 8px;
    border-radius: 4px;
}

.filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-footer {
    padding: 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .title {
        font-size: 22px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .controls-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-controls,
    .export-controls {
        width: 100%;
        justify-content: space-between;
    }

    .table-container {
        max-height: 400px;
    }

    .data-table {
        font-size: 12px;
    }

    .header-cell {
        padding: 10px 12px;
    }

    .data-table td {
        padding: 10px 12px;
    }
}

/* Refresh Feature Styles */
.refresh-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    transition: background 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.btn-refresh-all {
    padding: 10px 20px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-refresh-all:hover:not(:disabled) {
    background: #0ea570;
}

.btn-refresh-all:disabled,
.btn-refresh-all.disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    opacity: 0.6;
}

.refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--primary-color);
}

.refresh-btn:hover:not(:disabled) {
    background: var(--gray-100);
}

.refresh-btn:disabled,
.refresh-btn.disabled {
    cursor: not-allowed;
    opacity: 0.3;
    color: var(--gray-400);
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.refresh-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-success {
    border-left-color: var(--success-color);
}

.toast-error {
    border-left-color: var(--danger-color);
}

.toast-warning {
    border-left-color: var(--warning-color);
}

.toast-info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 20px;
    font-weight: bold;
}

.toast-success .toast-icon {
    color: var(--success-color);
}

.toast-error .toast-icon {
    color: var(--danger-color);
}

.toast-warning .toast-icon {
    color: var(--warning-color);
}

.toast-info .toast-icon {
    color: var(--primary-color);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--gray-700);
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    width: 24px;
    height: 24px;
}

.toast-close:hover {
    color: var(--gray-700);
}

/* Progress Modal */
.progress-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.progress-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    min-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.progress-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: var(--gray-800);
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #4f46e5);
    width: 0;
    transition: width 0.3s ease;
}

#progressText {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Row update animation */
.row-updated {
    animation: highlightRow 2s ease;
}

@keyframes highlightRow {
    0% {
        background: rgba(16, 185, 129, 0.2);
    }
    100% {
        background: transparent;
    }
}

.distance-cell,
.period-cell,
.status-cell {
    transition: all 0.3s ease;
}

/* Responsive adjustments for refresh controls */
@media (max-width: 768px) {
    .refresh-controls {
        width: 100%;
        justify-content: space-between;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .progress-content {
        min-width: 90%;
        padding: 20px;
    }
}

/* Print Styles */
@media print {
    .upload-section,
    .controls-section,
    .filter-btn,
    .refresh-btn,
    .toast-container,
    .progress-modal {
        display: none !important;
    }

    .table-section {
        box-shadow: none;
        border-radius: 0;
    }

    .data-table {
        font-size: 10px;
    }

    .header-content {
        background: none;
        color: black;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
/* Floating Avatar Animations */
@keyframes gentleBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

#floatingAvatar {
    animation: gentleBounce 3s ease-in-out infinite;
}

#floatingAvatar:hover {
    animation: none;
}

/* Pulse ring animation */
@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

#floatingAvatar .animate-ping {
    animation: pulseRing 2s ease-out infinite;
}

/* Credit popup entrance animation */
#creditModal {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover glow effect for avatar */
#floatingAvatar button::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 9999px;
    background: linear-gradient(45deg, #3b82f6, #8b5cf6);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    filter: blur(8px);
}

#floatingAvatar button:hover::after {
    opacity: 0.5;
}

/* WhatsApp button hover effect */
#creditPopup a {
    transform: translateY(0);
    transition: all 0.2s ease;
}

#creditPopup a:hover {
    transform: translateY(-2px);
}
