/* Import Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Main App Container - Light Theme */
#time-duration-calculator-final {
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    padding: 20px;
    border-radius: 16px;
    max-width:100%;
    margin: 40px auto;
    border: 1px solid #dee2e6;
}

/* Calculator Inner Wrapper */
.tdc-final-calculator-wrapper {
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Header */
.tdc-final-header {
    text-align: center;
    margin-bottom: 25px;
}
.tdc-final-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #343a40;
}

/* Form and Inputs */
.tdc-final-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Settings */
.tdc-final-settings {
    border: 1px solid #e9ecef;
    padding: 15px 20px;
    border-radius: 8px;
}
.tdc-final-settings-title {
    padding: 0 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #6c757d;
}
.tdc-final-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.tdc-final-checkbox-group input[type="checkbox"] { display: none; }
.tdc-final-checkbox-group label {
    cursor: pointer;
    padding: 5px 10px 5px 25px;
    position: relative;
    font-size: 0.95rem;
    color: #495057;
}
.tdc-final-checkbox-group label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #adb5bd;
    border-radius: 4px;
    transition: all 0.2s;
}
.tdc-final-checkbox-group input[type="checkbox"]:checked + label::before {
    background-color: #0d6efd;
    border-color: #0d6efd;
}
.tdc-final-checkbox-group input[type="checkbox"]:checked + label::after {
    content: '✔';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: white;
}

/* Time Input Rows */
.tdc-final-time-row { display: flex; align-items: flex-end; gap: 10px; }
.tdc-final-row-label { min-width: 80px; font-weight: 500; color: #495057; padding-bottom: 14px; }
.tdc-final-input-group { flex-grow: 1; }
.tdc-final-input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 5px;
    text-transform: uppercase;
}
.tdc-final-input-group input, .tdc-final-input-group select {
    width: 100%;
    padding: 12px;
    font-size: 1.2rem;
    color: #212529;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.tdc-final-input-group input:focus, .tdc-final-input-group select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}
.tdc-final-colon { font-size: 1.5rem; color: #adb5bd; padding-bottom: 8px; }

/* Controls */
.tdc-final-controls { display: flex; gap: 15px; justify-content: center; margin-top: 15px; }
.tdc-final-button {
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 1;
    max-width: 220px;
}
.tdc-final-button-calculate { background-color: #0d6efd; color: white; }
.tdc-final-button-calculate:hover { background-color: #0b5ed7; }
.tdc-final-button-clear { background-color: #e9ecef; color: #495057; border: 1px solid #ced4da; }
.tdc-final-button-clear:hover { background-color: #dee2e6; }

/* Results Section */
.tdc-final-results-section {
    display: none;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 25px;
    animation: tdc-final-fadeIn 0.5s ease;
}
@keyframes tdc-final-fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tdc-final-result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}
.tdc-final-result-header svg { width: 16px; height: 16px; }
.tdc-final-result-main {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: #343a40;
    margin-bottom: 15px;
}
.tdc-final-summary-text {
    text-align: center;
    font-size: 1rem;
    line-height: 1.6;
    color: #495057;
    margin-bottom: 25px;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}
.tdc-final-summary-text span {
    color: #0d6efd;
    font-weight: 600;
}

/* Results Table */
.tdc-final-results-table { width: 100%; border-collapse: collapse; }
.tdc-final-results-table th, .tdc-final-results-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}
.tdc-final-results-table tr:last-child td { border-bottom: none; }
.tdc-final-results-table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
}
.tdc-final-results-table td:last-child {
    text-align: right;
    font-weight: 500;
    color: #212529;
    font-family: 'Courier New', monospace;
}

/* Content & Visuals */
.tdc-final-content-wrapper { padding: 20px 10px 10px 10px; }
.tdc-final-content-section { margin-bottom: 30px; }
.tdc-final-content-heading {
    font-size: 1.6rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 15px;
    border-bottom: 2px solid #0d6efd;
    padding-bottom: 8px;
}
.tdc-final-content-subheading { font-size: 1.2rem; font-weight: 600; color: #343a40; margin-top: 25px; margin-bottom: 10px; }
.tdc-final-content-text { line-height: 1.8; color: #495057; }
.tdc-final-content-list { padding-left: 25px; }
.tdc-final-content-list li, .tdc-final-content-list ul li { margin-bottom: 10px; }

.tdc-calc-visual {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 25px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.tdc-calc-step { border-left: 3px solid #0d6efd; padding-left: 15px; }
.tdc-calc-step h4 { margin: 0 0 5px 0; color: #343a40; font-size: 1.1rem; }
.tdc-calc-step p { margin: 0 0 10px 0; font-size: 0.95rem; color: #6c757d; }
.tdc-calc-step code { display: block; background: #f8f9fa; padding: 8px 12px; border-radius: 6px; font-family: 'Courier New', monospace; }
.tdc-calc-final {
    text-align: center;
    background-color: #0d6efd;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}
.tdc-calc-final h4 { margin: 0; font-size: 1.1rem; }
.tdc-highlight { color: #0d6efd; font-weight: bold; }
.tdc-calc-visual .tdc-highlight { color: #0d6efd; }
.tdc-calc-final .tdc-highlight { color: #fff; }

/* Related Calculators */
.tdc-final-related-calculators { margin-top: 40px; padding-top: 20px; border-top: 1px solid #dee2e6; }
.tdc-final-related-title { font-size: 1.1rem; font-weight: 600; color: #495057; margin-bottom: 15px; }
.tdc-final-related-list { list-style: none; padding: 0; margin: 0; }
.tdc-final-related-list li { margin-bottom: 10px; }
.tdc-final-related-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
}
.tdc-final-related-link:hover { text-decoration: underline; }
.tdc-final-related-icon { width: 16px; height: 16px; }

/* Responsive */
@media (max-width: 600px) {
    .tdc-final-time-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        border: 1px solid #dee2e6;
        padding: 15px;
        border-radius: 10px;
    }
    .tdc-final-row-label { padding-bottom: 0; text-align: left; }
    .tdc-final-time-row .tdc-final-input-group { display: flex; justify-content: space-between; align-items: center; }
    .tdc-final-colon { display: none; }
    .tdc-final-controls { flex-direction: column; }
    .tdc-final-button { max-width: 100%; }
    .tdc-final-result-main { font-size: 1.8rem; }
}

/* --- Responsive Design --- */

/* For Tablets and smaller devices (e.g., iPad Landscape) */
@media (max-width: 1024px) {
    #time-duration-calculator-final {
        margin: 30px auto;
        padding: 15px;
    }
    .tdc-final-title {
        font-size: 1.6rem;
    }
    .tdc-final-result-main {
        font-size: 2rem;
    }
    .tdc-final-content-heading {
        font-size: 1.5rem;
    }
}


/* For smaller tablets (e.g., iPad Portrait) and large phones */
@media (max-width: 768px) {
    #time-duration-calculator-final {
        margin: 20px auto;
        border: none;
    }
    .tdc-final-calculator-wrapper,
    .tdc-final-results-section,
    .tdc-calc-visual {
        padding: 20px;
    }
    .tdc-final-title {
        font-size: 1.5rem;
    }
    .tdc-final-input-group input {
        font-size: 1.1rem;
        padding: 10px;
    }
    /* Stack control buttons for better touch targets */
    .tdc-final-controls {
        flex-direction: column;
        align-items: center;
    }
    .tdc-final-button {
        width: 100%;
        max-width: 320px; /* Give a max-width to avoid being overly wide */
    }
    .tdc-final-result-main {
        font-size: 1.9rem;
    }
    .tdc-final-content-wrapper {
        padding: 15px 5px;
    }
}


/* For most mobile phones */
@media (max-width: 600px) {
    #time-duration-calculator-final {
        padding: 0;
        margin: 0;
        border-radius: 0;
        background-color: #ffffff; /* Make background uniform on mobile */
    }
    .tdc-final-calculator-wrapper {
        margin-bottom: 20px;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #dee2e6;
    }
    .tdc-final-results-section {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Stack the time input rows for a vertical layout */
    .tdc-final-time-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    .tdc-final-row-label {
        padding-bottom: 0;
        min-width: auto;
        font-weight: 600;
        color: #343a40;
    }
    .tdc-final-colon {
        display: none; /* Hide colons as they don't make sense in a stacked layout */
    }
    .tdc-final-input-group {
        display: flex; /* Allow inputs to align in a row within the group */
        gap: 10px;
    }

    /* Adjust checkbox layout for smaller screens */
    .tdc-final-checkbox-group {
        gap: 10px 15px;
        justify-content: center;
    }
    .tdc-final-checkbox-group label {
        font-size: 0.9rem;
        padding-bottom: 10px;
    }

    /*
     * Responsive Table: Transform to a "card" view on mobile.
     * IMPORTANT: For this to work correctly, you must add a `data-label` attribute
     * to each `<td>` in your HTML, corresponding to its column header.
     * Example: <td data-label="Unit">Years</td>
     *          <td data-label="Value">2.75</td>
    */
    .tdc-final-results-table {
        border: none;
    }
    .tdc-final-results-table thead {
        display: none; /* Hide original table headers */
    }
    .tdc-final-results-table tr {
        display: block;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 10px;
    }
    .tdc-final-results-table tr:last-child {
        margin-bottom: 0;
    }
    .tdc-final-results-table td {
        display: block;
        text-align: right !important; /* Override original style */
        font-size: 1rem;
        padding: 10px 5px;
        border-bottom: 1px dashed #e9ecef;
    }
    .tdc-final-results-table tr td:last-child {
        border-bottom: 0;
    }
    /* Add labels using pseudo-elements and the data-label attribute from your HTML */
    .tdc-final-results-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: #6c757d;
        font-family: 'Inter', sans-serif;
        text-transform: uppercase;
        font-size: 0.8rem;
    }
}


/* For smaller mobile phones */
@media (max-width: 400px) {
    .tdc-final-calculator-wrapper,
    .tdc-final-results-section,
    .tdc-calc-visual {
        padding: 20px 15px;
    }
    .tdc-final-title {
        font-size: 1.3rem;
    }
    .tdc-final-input-group label {
        font-size: 0.7rem;
    }
    .tdc-final-input-group input,
    .tdc-final-input-group select {
        font-size: 1rem;
        padding: 10px 8px;
    }
    .tdc-final-button {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    .tdc-final-result-main {
        font-size: 1.6rem;
    }
    .tdc-final-summary-text {
        font-size: 0.95rem;
    }
    .tdc-final-content-heading {
        font-size: 1.25rem;
    }
    .tdc-final-content-subheading {
        font-size: 1.1rem;
    }
    .tdc-final-content-text {
        font-size: 0.9rem;
        line-height: 1.7;
    }
}