/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

:root {
    --primary-color: #007BFF;
    --primary-hover: #0056B3;
    --secondary-color: #6C757D;
    --light-bg: #FFFFFF;
    --accent-light: #F8F9FA;
    --accent-medium: #E9ECEF;
    --border-color: #DEE2E6;
    --text-primary: #212529;
    --text-secondary: #6C757D;
    --text-light: #ADB5BD;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    background-color: var(--accent-light);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    background-color: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 0;
    margin-bottom: 30px;
    text-align: center;
    border: 1px solid black;
    border-radius: var(--radius-md);
}

h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Main Content Styles */
main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 800px;
    margin: 0 auto;
}

/* Input Panel Styles */
.input-panel {
    background-color: var(--light-bg);
    border: 1px solid black;
    border-radius: var(--radius-md);
    padding: 24px;
    width: 100%;
}

.form-group {
    margin-bottom: 22px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

select, input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background-color: var(--light-bg);
    color: var(--text-primary);
    border: 1px solid black;
}

select:hover, input[type="number"]:hover {
    border-color: var(--primary-color);
    background-color: var(--accent-light);
}

select:focus, input[type="number"]:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.error-message {
    color: #DC3545;
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.radio-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background-color: var(--accent-light);
    transition: all 0.2s ease;
}

.radio-container:hover {
    background-color: var(--accent-medium);
}

input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.radio-label {
    font-size: 15px;
    color: var(--text-primary);
}

.info-text {
    background-color: var(--accent-light);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-top: 15px;
    border-left: 3px solid var(--primary-color);
}

.info-text p {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.quality-info {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
}

.quality-info li {
    margin-bottom: 6px;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0);
}

#calculate-btn {
    background-color: var(--primary-color);
    color: #FFFFFF;
}

#calculate-btn:hover {
    background-color: var(--primary-hover);
}

#reset-btn {
    background-color: var(--secondary-color);
    color: #FFFFFF;
}

#reset-btn:hover {
    background-color: #5A6268;
}

/* Result Panel Styles */
.result-panel {
    background-color: var(--light-bg);
    border: 1px solid black;
    border-radius: var(--radius-md);
    padding: 24px;
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    width: 100%;
}

.result-panel.active {
    display: block;
    opacity: 1;
}

.total-cost {
    background-color: #ffffff;
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 25px;
    width: 100%;
}

.visualization {
    margin: 30px 0;
}

.cost-breakdown {
    margin: -30px 0;
}

.resource-allocation {
    margin: 30px 0;
    background-color: var(--light-bg);
    border-radius: var(--radius-md);
    padding: 24px;
   
}

.resource-allocation h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.resource-info {
    background-color: var(--accent-light);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border: 1px solid black;
}

.resource-info p {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 375px) {
    .resource-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.resource-card {
    background-color: var(--light-bg);
    border: 1px solid black;
    border-radius: var(--radius-md);
    padding: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    min-width: 0;
}

.resource-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.resource-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.resource-emoji {
    font-size: 24px;
}

.resource-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.resource-details {
    display: grid;
    gap: 12px;
    width: 100%;
    overflow-wrap: break-word;
}

.resource-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.resource-detail-label {
    color: var(--text-secondary);
    font-size: 14px;
    min-width: 0;
}

.resource-detail-value {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 0;
    text-align: right;
}

.resource-quality {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    overflow-wrap: break-word;
    margin-top: 10px;
}

.quality-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background-color: var(--accent-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.quality-option:hover {
    background-color: var(--accent-medium);
}

.quality-option input[type="radio"] {
    margin: 0;
}

.quality-option input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.resource-amount {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

.timeline {
    margin: 30px 0;
}

.cost-value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 10px;
    color: var(--primary-color);
}

h2, h3 {
    color: var(--text-primary);
}

h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

h3 {
    font-size: 20px;
    margin-bottom: 15px;
    position: relative;
    padding-bottom: 8px;
}

h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

.chart-container {
    height: 300px;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--accent-light);
    font-weight: 600;
    color: var(--text-primary);
}

tr:hover {
    background-color: rgba(0, 123, 255, 0.03);
}

tr:nth-child(even) {
    background-color: var(--accent-light);
}

.timeline-container {
    margin: 25px 0;
    background-color: var(--light-bg);
    border-radius: var(--radius-md);
    padding: 15px;
    border: 1px solid black;
}

.overall-duration {
    font-weight: 600;
    margin-bottom: 15px;
    text-align: center;
    padding: 10px;
    background-color: var(--accent-light);
    border-radius: var(--radius-sm);
}

.timeline-item {
    display: flex;
    margin-bottom: 15px;
    align-items: center;
}

.timeline-label {
    width: 30%;
    font-size: 15px;
    padding-right: 15px;
    font-weight: 500;
}

.timeline-bar-container {
    width: 50%;
    height: 22px;
    background-color: var(--accent-light);
    border-radius: 11px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeline-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 11px 0 0 11px;
}

.timeline-value {
    width: 20%;
    font-size: 14px;
    padding-left: 15px;
    color: var(--text-secondary);
}

.print-share {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

#print-btn, #share-btn {
    padding: 12px 24px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--light-bg);
    color: var(--text-primary);
    border: 1px solid black;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    width: 200px;
}

#print-btn:hover, #share-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#print-btn:active, #share-btn:active {
    transform: translateY(0);
}

#print-btn::before {
    content: '🖨️';
}

#share-btn::before {
    content: '📤';
}

/* Resource Allocation Table Styles */
#resource-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#resource-table th, 
#resource-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#resource-table th {
    background-color: var(--accent-light);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

#resource-table tr:hover {
    background-color: rgba(0, 123, 255, 0.03);
}

#resource-table tr:nth-child(even) {
    background-color: var(--accent-light);
}

.resource-emoji {
    font-size: 22px;
    margin-right: 10px;
    vertical-align: middle;
}

.resource-name {
    display: flex;
    align-items: center;
    font-weight: 500;
}

.unit-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 5px;
}

.quality-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quality-option {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
    font-size: 14px;
    padding: 4px 0;
}

.quality-option input[type="radio"] {
    margin-right: 8px;
}

.quality-option input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.total-row {
    background-color: #FFF9E6 !important;
    font-weight: 700;
}

.total-row td {
    padding: 14px 15px;
    border-top: 2px solid var(--border-color);
}

.resource-cost {
    font-weight: 500;
    color: var(--primary-color);
}

/* Tooltip styling */
[data-tooltip] {
    position: relative;
    cursor: help;
    border: 1px solid black;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    padding: 8px 12px;
    background-color: var(--text-primary);
    color: white;
    font-size: 13px;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Highlight animation for dynamic changes */
@keyframes highlight {
    0% {
        background-color: rgba(0, 123, 255, 0.2);
    }
    50% {
        background-color: rgba(0, 123, 255, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

.highlight-change {
    animation: highlight 1.5s ease-in-out;
}

.unit-cost-container {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid black;
}

.unit-cost {
    font-size: 18px;
    color: var(--text-secondary);
    margin: -3px 0px;
}

.unit-cost span {
    font-weight: 600;
    color: var(--primary-color);
}

/* Add specific styles for very small mobile screens */
@media (max-width: 375px) {
    /* Improve overall container spacing */
    .container {
        padding: 10px 5px;
    }
    
    /* Adjust header for small screens */
    h1 {
        font-size: 18px;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    /* Adjust form elements */
    .form-group {
        margin-bottom: 15px;
    }
    
    label {
        font-size: 14px;
    }
    
    select, input[type="number"] {
        padding: 10px;
        font-size: 14px;
        border: 1px solid black;
    }
    
    /* Adjust result panel */
    .result-panel {
        padding: 12px;
    }
    
    .cost-value {
        font-size: 22px;
    }
    
    .unit-cost {
        font-size: 13px;
    }
    
    /* Improve table responsiveness */
    th, td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    /* Resource allocation section improvements */
    .resource-allocation {
        padding: 10px;
        margin: 20px 0;
    }
    
    .resource-allocation h3 {
        font-size: 16px;
        margin-bottom: 15px;
        gap: 5px;
    }
    
    .resource-info {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .resource-info p {
        font-size: 12px;
        gap: 5px;
    }
    
    .resource-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-top: 15px;
    }
    
    #resource-table th, 
    #resource-table td {
        padding: 8px 5px;
        font-size: 12px;
    }
    
    .resource-emoji {
        font-size: 16px;
        margin-right: 5px;
    }
    
    .resource-name {
        font-size: 13px;
    }
    
    .unit-text {
        font-size: 10px;
    }
    
    .quality-cell {
        gap: 5px;
    }
    
    .quality-option {
        padding: 3px 0;
        font-size: 12px;
    }
    
    .quality-option input[type="radio"] {
        margin-right: 5px;
        transform: scale(0.9);
    }
    
    .resource-cost {
        font-size: 13px;
    }
    
    .total-row td {
        padding: 10px 5px;
    }
    
    /* Improve timeline section specifically */
    .timeline h3 {
        font-size: 16px;
    }
    
    .timeline-container {
        padding: 10px 8px;
        margin: 15px 0;
    }
    
    .timeline-item {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px dashed var(--border-color);
    }
    
    .timeline-item:last-child {
        border-bottom: none;
    }
    
    .timeline-label {
        width: 100%;
        font-size: 14px;
        padding-right: 0;
        margin-bottom: 8px;
        font-weight: 600;
    }
    
    .timeline-bar-container {
        width: 100%;
        height: 16px;
        margin-bottom: 5px;
        border-radius: 8px;
    }
    
    .timeline-bar {
        border-radius: 8px 0 0 8px;
    }
    
    .timeline-value {
        width: 100%;
        padding-left: 0;
        font-size: 13px;
        text-align: right;
    }
    
    .overall-duration {
        font-size: 14px;
        padding: 8px;
    }
    
    /* Adjust print and share buttons */
    .print-share {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    
    #print-btn, #share-btn {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }
    
    /* Adjust container padding */
    .container {
        padding: 10px;
    }
    
    /* Adjust resource cards */
    .resource-card {
        padding: 8px;
        border: 1px solid black;
    }
    
    .resource-header {
        gap: 5px;
    }
    
    .resource-emoji {
        font-size: 18px;
    }
    
    .resource-name {
        font-size: 14px;
    }
    
    .resource-detail-label,
    .resource-detail-value {
        font-size: 13px;
    }
    
    .quality-option {
        padding: 5px;
    }
    
    .resource-amount {
        font-size: 14px;
        margin-top: 8px;
        padding-top: 8px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 24px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .input-panel, .result-panel {
        padding: 20px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 10px;
    }
    
    button {
        width: 100%;
    }
    
    .resource-grid {
        grid-template-columns: 1fr;
    }
    
    .resource-card {
        padding: 12px;
    }
    
    .resource-header {
        margin-bottom: 12px;
    }
    
    .resource-emoji {
        font-size: 20px;
    }
    
    .resource-name {
        font-size: 15px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0px;
    }
    
    .input-panel, .result-panel {
        padding: 15px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .cost-value {
        font-size: 24px;
    }
    
    .chart-container {
        height: 355px;
    }
    
    .table-responsive {
        margin: 0 -15px;
        padding: 0 15px;
        overflow-x: auto;
    }
    
    .resource-allocation {
        padding: 15px;
    }
    
    .resource-info {
        padding: 12px;
    }
    
    .resource-card {
        padding: 10px;
    }
    
    .quality-option {
        padding: 6px;
        font-size: 14px;
    }
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Table responsive container */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
    margin: 0;
}

@media (max-width: 375px) {
    .table-responsive {
        margin: 0 0px;
        width: calc(100% + 20px);
        padding: 0;
    }
}

/* Footer styling */
footer {
    background-color: var(--light-bg);
    color: var(--text-secondary);
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.disclaimer {
    font-size: 14px;
    line-height: 1.6;
}

/* Icon styling */
i.fas {
    margin-right: 8px;
    color: #007bff;
}

/* Specific styling for calculate and reset button icons */
#calculate-btn i.fas,
#reset-btn i.fas {
    color: white;
}

@media print {
    .input-panel, header, footer, .print-share {
        display: none;
    }
    
    .result-panel {
        display: block !important;
        opacity: 1 !important;
        box-shadow: none;
        border: none;
    }
    
    body {
        background-color: white;
    }
}

.unit-cost-header {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.formula-explanation {
    background-color: var(--accent-light);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin: 15px 0;
    border-left: 3px solid var(--primary-color);
}

.formula-explanation h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.formula-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.formula-box {
    background-color: white;
    border-radius: var(--radius-sm);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.formula-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.formula-math {
    font-family: "Courier New", monospace;
    background-color: rgba(0, 123, 255, 0.1);
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
    text-align: center;
}

.formula-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.rate-per-sqft {
    display: inline-block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 6px;
    font-weight: normal;
}

@media (max-width: 768px) {
    .formula-grid {
        grid-template-columns: 1fr;
    }
}