/* Portfolio Return Calculator - Mobile First Responsive Design */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.portfolio-calculator-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #ffffff;
    color: #2D3748;
    line-height: 1.6;
    max-width: 100%;
    overflow-x: hidden;
    padding: 1rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: #1A202C;
    letter-spacing: -0.025em;
}

h1 {
    font-size: 1.75rem;
    text-align: center;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

p {
    margin-bottom: 1rem;
    color: #4A5568;
}

/* Title Section */
.calculator-title-section {
    background: #2CEC00;
    color: #ffffff;
    text-align: center;
    padding: 2rem 1rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.calculator-title-section p {
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.05rem;
    margin-bottom: 0;
    font-weight: 400;
}

/* Card Styling */
.input-grid,
.summary-cards,
.breakdown-grid,
.calculator-input-section,
.calculator-results-section {
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Input Section */
.input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 500;
    font-size: 0.95rem;
    color: #4A5568;
    margin-bottom: 2px;
}

.input-group input,
.input-group select {
    padding: 0.875rem 1rem;
    border: 2px solid #E2E8F0;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #F8FAFC;
    transition: all 0.2s ease;
    min-height: 48px;
    width: 100%;
    font-family: inherit;
    color: #2D3748;
}

.input-group input:hover,
.input-group select:hover {
    border-color: #CBD5E0;
    background-color: #ffffff;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #22c55e;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.input-group input[type="number"] {
    -moz-appearance: textfield;
}

.input-group input[type="number"]::-webkit-outer-spin-button,
.input-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Error Messages */
.error-message {
    color: #E53E3E;
    font-size: 0.875rem;
    min-height: 1.25rem;
    display: none;
    margin-top: 4px;
    font-weight: 500;
}

.error-message.active {
    display: block;
}

.input-group input.error {
    border-color: #E53E3E;
    background-color: #FEF2F2;
}

/* Advanced Options Toggle */
.advanced-options-toggle {
    text-align: center;
    margin: 1.5rem 0;
}

.toggle-icon {
    display: inline-block;
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.toggle-icon.open {
    transform: rotate(180deg);
}

.advanced-options {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Button Styles */
.primary-button,
.secondary-button {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    margin-bottom: 0.75rem;
    font-family: inherit;
    letter-spacing: 0.02em;
}

.primary-button {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.25);
}

.primary-button:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803D 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.secondary-button {
    background: linear-gradient(135deg, #2563eb 0%, #1D4ED8 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.secondary-button:hover {
    background: linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    margin-top: 1rem;
}

.spinner {
    border: 3px solid rgba(34, 197, 94, 0.1);
    border-top-color: #22c55e;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Results Section */
.calculator-results-section {
    display: none;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Summary Cards - Updated with relaxing colors */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #CBD5E0;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 10px 10px 0 0;
    z-index: -1;
}

.summary-card:nth-child(1)::before {
    background: linear-gradient(90deg, #22c55e 0%, #4ADE80 100%);
}

.summary-card:nth-child(2)::before {
    background: linear-gradient(90deg, #2563eb 0%, #60A5FA 100%);
}

.summary-card:nth-child(3)::before {
    background: linear-gradient(90deg, #7C3AED 0%, #A78BFA 100%);
}

.summary-card:nth-child(4)::before {
    background: linear-gradient(90deg, #EA580C 0%, #FB923C 100%);
}

.summary-card h3 {
    font-size: 0.95rem;
    color: #64748B;
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    word-break: break-word;
    font-family: 'Inter', sans-serif;
    padding: 0 0.5rem;
}

.summary-label {
    font-size: 0.875rem;
    color: #64748B;
    margin-bottom: 0;
    font-weight: 400;
}

/* Progress Bar */
.progress-section {
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.progress-bar-container {
    margin-top: 1rem;
}

.progress-bar {
    height: 1.25rem;
    background-color: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #4ADE80 100%);
    width: 0%;
    transition: width 1s ease;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #64748B;
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chart-container h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: #1E293B;
}

.chart-container canvas {
    width: 100% !important;
    height: 250px !important;
}

/* Breakdown Section */
.breakdown-section {
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}

.breakdown-item span:first-child {
    font-size: 0.875rem;
    color: #64748B;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.breakdown-item span:last-child {
    font-size: 1.125rem;
    color: #1E293B;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

/* Timeline Table */
.timeline-section {
    background-color: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    margin-top: 1rem;
}

#timeline-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    background: #ffffff;
}

#timeline-table thead {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
}

#timeline-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #E2E8F0;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#timeline-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #F1F5F9;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
}

#timeline-table tbody tr:hover {
    background-color: #F8FAFC;
}

#timeline-table tbody tr:last-child td {
    border-bottom: none;
}

/* Results Action Buttons */
.results-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* Responsive Design */

/* Tablet: 481px - 768px */
@media (min-width: 481px) {
    h1 {
        font-size: 2rem;
    }
    
    .input-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        flex-direction: row;
    }
    
    .primary-button,
    .secondary-button {
        width: auto;
        margin-bottom: 0;
        flex: 1;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .breakdown-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .summary-value {
        font-size: 1.75rem;
    }
}

/* Desktop: > 768px */
@media (min-width: 769px) {
    .portfolio-calculator-wrapper {
        padding: 2rem;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    h1 {
        font-size: 2.25rem;
    }
    
    .charts-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .breakdown-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .chart-container canvas {
        height: 300px !important;
    }
    
    .summary-value {
        font-size: 2rem;
        padding: 0 1rem;
    }
    
    .summary-card {
        min-height: 160px;
        padding: 1.5rem;
    }
}

/* Small Mobile: ≤ 360px */
@media (max-width: 360px) {
    .portfolio-calculator-wrapper {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .calculator-title-section,
    .calculator-input-section,
    .calculator-results-section {
        padding: 1rem;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .results-actions {
        grid-template-columns: 1fr;
    }
    
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-card {
        min-height: auto;
        padding: 1rem;
    }
    
    .summary-value {
        font-size: 1.25rem;
        padding: 0;
    }
}

/* Large Amounts Handling */
@media (min-width: 481px) {
    .summary-card {
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .summary-value {
        font-size: clamp(1.25rem, 2vw, 2rem);
        line-height: 1.1;
    }
}

/* Print Styles */
@media print {
    .portfolio-calculator-wrapper {
        background: white;
        padding: 0;
        font-size: 12pt;
    }
    
    .primary-button,
    .secondary-button,
    .advanced-options-toggle,
    .action-buttons,
    .loading-indicator,
    .results-actions {
        display: none !important;
    }
    
    .calculator-input-section,
    .calculator-results-section {
        border: none;
        background: white;
        padding: 0;
        box-shadow: none;
    }
    
    .summary-cards,
    .charts-section,
    .breakdown-section,
    .timeline-section {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 1cm;
    }
    
    .summary-cards {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .chart-container canvas {
        height: 200px !important;
    }
    
    .table-container {
        overflow: visible;
    }
    
    #timeline-table {
        min-width: auto;
        font-size: 10pt;
    }
    
    .summary-value {
        font-size: 14pt;
        color: black !important;
    }
    
    h1, h2, h3 {
        color: black !important;
    }
}

/* Accessibility */
.primary-button:focus,
.secondary-button:focus,
.input-group input:focus,
.input-group select:focus {
    outline: 3px solid rgba(34, 197, 94, 0.4);
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Custom Scrollbar */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}