/* ========================================
   Mileage Calculator Styles
   ======================================== */

:root {
    --mileage-primary: #0d6efd;
    --mileage-success: #198754;
    --mileage-danger: #dc3545;
    --mileage-warning: #ffc107;
    --mileage-info: #0dcaf0;
    --mileage-light: #f8f9fa;
    --mileage-dark: #212529;
    --mileage-border: #dee2e6;
}

/* Container */
.mileage-calculator-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
.calculator-header {
    text-align: center;
    margin-bottom: 2rem;
}

.calculator-header h1 {
    color: var(--mileage-dark);
    margin-bottom: 1rem;
    font-size: 2.5rem;
    font-weight: 700;
}

.calculator-header .lead {
    color: #6c757d;
    font-size: 1.125rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Mode Selection */
.mode-selection .btn-check:checked + .btn-outline-primary {
    background-color: var(--mileage-primary);
    color: white;
    border-color: var(--mileage-primary);
}

/* Settings Panel */
.settings-panel .card-header {
    background-color: var(--mileage-light);
    border-bottom: 2px solid var(--mileage-border);
}

/* Table Styling */
.table-responsive {
    overflow-x: auto;
}

#logEntriesTable {
    min-width: 1000px;
}

#logEntriesTable th {
    background-color: var(--mileage-light);
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

#logEntriesTable td {
    vertical-align: middle;
}

#logEntriesTable input.form-control-sm {
    min-width: 100px;
}

#logEntriesTable input[type="date"],
#logEntriesTable input[type="time"] {
    min-width: 130px;
}

#logEntriesTable input[type="number"] {
    min-width: 90px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons .btn {
    min-width: 150px;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-box {
    text-align: center;
    padding: 1.5rem;
    background: var(--mileage-light);
    border-radius: 0.5rem;
    height: 100%;
}

.result-box.highlight {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid var(--mileage-success);
}

.result-label {
    font-size: 0.875rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--mileage-dark);
    line-height: 1.2;
}

.result-value.text-success {
    color: var(--mileage-success) !important;
}

/* Signature Section */
.signature-section {
    margin-top: 3rem;
    padding: 2rem;
}

.signature-line {
    margin-bottom: 2rem;
}

/* SEO Content */
.seo-content {
    background: #fafafa;
    border-radius: 0.5rem;
}

.seo-content h2,
.seo-content h3,
.seo-content h4 {
    color: var(--mileage-dark);
    margin-top: 1.5rem;
}

.seo-content ul,
.seo-content ol {
    margin-left: 1.5rem;
}

/* Accessibility Enhancements */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Hide print-only content on screen */
.print-only {
    display: none;
}

/* Hide screen-only content in print (handled in print section) */
@media screen {
    .screen-only {
        display: block;
    }
}

.form-control:focus,
.form-select:focus,
.btn-check:focus + .btn {
    border-color: var(--mileage-primary);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.text-danger {
    color: var(--mileage-danger);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .result-box {
        border: 2px solid var(--mileage-dark);
    }

    .card {
        border-width: 2px;
    }

    .btn {
        border-width: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .results-section {
        animation: none;
    }

    * {
        transition: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --mileage-light: #343a40;
        --mileage-dark: #f8f9fa;
        --mileage-border: #495057;
    }

    body {
        background-color: #212529;
        color: #f8f9fa;
    }

    .card {
        background-color: #2c3136;
        border-color: #495057;
    }

    .result-box {
        background-color: #343a40;
    }

    .table {
        color: #f8f9fa;
    }

    .form-control,
    .form-select {
        background-color: #343a40;
        border-color: #495057;
        color: #f8f9fa;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    @page {
        size: letter;
        margin: 0.75in;
    }

    /* Hide screen-only elements */
    .no-print,
    .screen-only,
    .mode-selection,
    .settings-panel,
    .action-buttons,
    .seo-content,
    .alert,
    nav,
    footer,
    header,
    button,
    .calculator-header,
    #mileageForm,
    form,
    .card:not(.print-only),
    .table-responsive:not(.print-only),
    #quickTotalSection,
    #weeklyLogSection,
    #logEntriesTable,
    .results-section:not(.print-only),
    .result-box:not(.print-only),
    [class*="btn"],
    input,
    select,
    textarea,
    .form-control,
    .form-select,
    .form-check,
    .navbar,
    .breadcrumb,
    .pagination,
    .toast,
    .modal,
    .offcanvas,
    .dropdown-menu {
        display: none !important;
    }

    /* Show print-only elements */
    .print-only {
        display: block !important;
    }

    /* Reset container */
    .mileage-calculator-container {
        max-width: 100%;
        padding: 0;
    }

    /* Print Report Styles */
    .mileage-report {
        width: 100%;
        font-family: Arial, sans-serif;
        color: #000;
        background: #fff;
    }

    .report-header {
        text-align: center;
        border-bottom: 3px solid #000;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }

    .report-header h1 {
        font-size: 24pt;
        font-weight: bold;
        margin: 0 0 0.5rem 0;
        color: #000;
    }

    .report-meta {
        display: flex;
        justify-content: center;
        gap: 2rem;
        font-size: 10pt;
    }

    .meta-item {
        margin: 0;
    }

    .report-section {
        margin-bottom: 1.5rem;
        page-break-inside: avoid;
    }

    .report-section h2 {
        font-size: 14pt;
        font-weight: bold;
        border-bottom: 2px solid #333;
        padding-bottom: 0.25rem;
        margin: 0 0 0.75rem 0;
        color: #000;
    }

    /* Summary Table */
    .summary-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 1rem;
    }

    .summary-table tr {
        border-bottom: 1px solid #ddd;
    }

    .summary-table td {
        padding: 0.5rem;
        font-size: 11pt;
    }

    .summary-table .label-col {
        width: 40%;
        font-weight: 600;
    }

    .summary-table .value-col {
        width: 60%;
    }

    .summary-table .total-row {
        border-top: 2px solid #000;
        border-bottom: 2px solid #000;
        background: #f5f5f5;
    }

    .summary-table .total-row td {
        padding: 0.75rem 0.5rem;
        font-size: 12pt;
    }

    /* Details Table */
    .details-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
        margin-bottom: 1rem;
    }

    .details-table th {
        background: #333;
        color: #fff;
        padding: 0.5rem;
        text-align: left;
        font-weight: bold;
        border: 1px solid #000;
    }

    .details-table td {
        padding: 0.4rem;
        border: 1px solid #ccc;
    }

    .details-table tbody tr:nth-child(odd) {
        background: #f9f9f9;
    }

    .details-table .text-end {
        text-align: right;
    }

    .details-table .notes-row td {
        font-size: 8pt;
        font-style: italic;
        background: #fff !important;
        border-top: none;
        padding-top: 0;
    }

    .details-table tfoot {
        border-top: 3px solid #000;
    }

    .details-table tfoot td {
        padding: 0.6rem 0.4rem;
        font-weight: bold;
        background: #f0f0f0;
        font-size: 10pt;
    }

    /* Signature Section */
    .signature-section {
        margin-top: 2rem;
        page-break-inside: avoid;
        border-top: 2px solid #000;
        padding-top: 1rem;
    }

    .signature-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 2rem;
    }

    .signature-box {
        width: 48%;
    }

    .signature-line {
        border-bottom: 1px solid #000;
        height: 40px;
        margin-bottom: 0.25rem;
    }

    .signature-label {
        font-size: 9pt;
        font-weight: 600;
        color: #555;
    }

    /* Report Footer */
    .report-footer {
        margin-top: 1.5rem;
        font-size: 8pt;
        border-top: 1px solid #ccc;
        padding-top: 0.5rem;
    }

    .report-footer p {
        margin: 0.25rem 0;
    }

    .report-footer .small {
        font-size: 7pt;
        color: #666;
    }
    
    /* OfficeSeries Branding Footer */
    .report-footer .powered-by {
        text-align: center;
        font-weight: bold;
        font-size: 9pt;
        margin-top: 1rem;
        padding-top: 0.5rem;
        border-top: 2px solid #000;
        color: #000 !important;
    }

    /* Force black text for all print content */
    .print-only,
    .print-only * {
        color: #000 !important;
        background: transparent !important;
    }

    /* Preserve table backgrounds */
    .details-table th {
        background: #333 !important;
        color: #fff !important;
    }

    .details-table tbody tr:nth-child(odd) {
        background: #f9f9f9 !important;
    }

    .details-table tfoot td,
    .summary-table .total-row {
        background: #f0f0f0 !important;
    }
}

/* ========================================
   Responsive Styles
   ======================================== */

@media (max-width: 768px) {
    .calculator-header h1 {
        font-size: 1.75rem;
    }

    .calculator-header .lead {
        font-size: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .result-value {
        font-size: 1.5rem;
    }

    /* Make table scrollable on mobile */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #logEntriesTable input {
        min-width: 80px;
    }
}

@media (max-width: 576px) {
    .mileage-calculator-container {
        padding: 1rem 0.5rem;
    }

    .calculator-header h1 {
        font-size: 1.5rem;
    }

    .result-value {
        font-size: 1.25rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* ========================================
   Loading State
   ======================================== */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--mileage-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Focus Visible for Keyboard Navigation
   ======================================== */

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 3px solid var(--mileage-primary);
    outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--mileage-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}
