/* 
 * Life Insurance Premium Calculator - Style.css
 * Mobile-first responsive design
 */

/* ============================================
   RESET & BASE STYLES
   ============================================ */
.life-insurance-calculator-wrapper {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #111827;
    background: #ffffff;
    padding: 0;
    margin: 0 auto;
}

.life-insurance-calculator-wrapper *,
.life-insurance-calculator-wrapper *::before,
.life-insurance-calculator-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   TITLE SECTION
   ============================================ */
.calculator-title-container {
    background: #2CEC00;
    color: #ffffff;
    text-align: center;
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 100%;
}

.calculator-title-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.calculator-title-container p {
    font-size: 0.875rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   CALCULATOR CONTAINER
   ============================================ */
.calculator-container {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 2rem;
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

/* ============================================
   INPUT SECTION
   ============================================ */
.input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.input-group label .required {
    color: #ef4444;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #111827;
    min-height: 44px; /* Touch-friendly */
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.input-group input.error,
.input-group select.error {
    border-color: #ef4444;
}

.error-message {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.25rem;
    min-height: 1rem;
}

/* ============================================
   ADVANCED OPTIONS
   ============================================ */
.advanced-options-toggle {
    margin-bottom: 1.5rem;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.toggle-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.toggle-icon {
    transition: transform 0.2s;
}

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

.advanced-options {
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease-out;
}

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

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

.checkbox-group input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
}

.checkbox-group label {
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
}

.riders-options {
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
}

/* ============================================
   CALCULATE BUTTON & LOADING
   ============================================ */
.calculate-button-container {
    position: relative;
    margin-top: 2rem;
}

.calculate-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background: #22c55e;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculate-btn:hover {
    background: #16a34a;
}

.calculate-btn:active {
    transform: translateY(1px);
}

.calculate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(249, 250, 251, 0.95);
    border-radius: 0.5rem;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #22c55e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator span {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================
   RESULTS SECTION
   ============================================ */
.results-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e5e7eb;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   SUMMARY CARDS
   ============================================ */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: #000000;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.25rem;
}

.card-subtitle {
    font-size: 0.75rem;
    color: #ffffff;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-section {
    margin-bottom: 2rem;
}

.progress-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #374151;
}

.progress-bar {
    height: 0.75rem;
    background: #e5e7eb;
    border-radius: 0.375rem;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: #22c55e;
    border-radius: 0.375rem;
    transition: width 0.5s ease-out;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ============================================
   CHARTS CONTAINER
   ============================================ */
.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-wrapper {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    height: 300px;
    position: relative;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   DETAILED BREAKDOWN
   ============================================ */
.detailed-breakdown {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.detailed-breakdown h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #374151;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-label {
    font-size: 0.875rem;
    color: #374151;
}

.breakdown-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.breakdown-total {
    border-top: 2px solid #e5e7eb;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.breakdown-total .breakdown-label {
    font-weight: 600;
    color: #111827;
}

.breakdown-total .breakdown-value {
    font-size: 1rem;
    color: #22c55e;
}

.breakdown-final {
    background: #f0fdf4;
    border-radius: 0.375rem;
    padding: 1rem !important;
    margin-top: 0.5rem !important;
    border: 2px solid #22c55e !important;
}

.breakdown-final .breakdown-label {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.breakdown-final .breakdown-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #16a34a;
}

/* ============================================
   TIMELINE TABLE
   ============================================ */
.timeline-section {
    margin-bottom: 2rem;
}

.timeline-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #374151;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #ffffff;
}

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

#premium-timeline-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

#premium-timeline-table th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

#premium-timeline-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}

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

#premium-timeline-table tbody tr:hover {
    background: #f9fafb;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 2rem;
}

.secondary-btn,
.reset-btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.secondary-btn {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.secondary-btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.reset-btn {
    background: #ffffff;
    color: #374151;
}

.reset-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* ============================================
   ERROR CONTAINER
   ============================================ */
.error-container {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    color: #dc2626;
    font-size: 0.875rem;
    display: none;
}

.error-container ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.error-container li {
    margin-bottom: 0.25rem;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .life-insurance-calculator-wrapper {
        background: #ffffff;
    }
    
    .calculate-btn,
    .toggle-btn,
    .secondary-btn,
    .reset-btn,
    .advanced-options-toggle,
    .checkbox-group input,
    .checkbox-group label {
        display: none !important;
    }
    
    .calculator-title-container {
        background: #ffffff !important;
        color: #000000 !important;
        border: 2px solid #000000;
    }
    
    .calculator-container {
        border: 1px solid #000000;
        background: #ffffff;
    }
    
    .summary-cards,
    .charts-container,
    .detailed-breakdown,
    .timeline-section {
        break-inside: avoid;
    }
    
    .chart-wrapper {
        height: 250px;
    }
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet (481px - 768px) */
@media (min-width: 481px) {
    .calculator-title-container {
        padding: 2rem 1.5rem;
    }
    
    .calculator-title-container h1 {
        font-size: 1.75rem;
    }
    
    .calculator-container {
        padding: 2rem;
    }
    
    .input-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.25rem;
    }
    
    .card-title {
        font-size: 0.8125rem;
    }
    
    .card-value {
        font-size: 1.75rem;
    }
    
    .charts-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop (> 768px) */
@media (min-width: 769px) {
    .life-insurance-calculator-wrapper {
        max-width: 1200px;
        padding: 0 1rem;
    }
    
    .calculator-title-container {
        padding: 2.5rem 2rem;
        margin-bottom: 2rem;
    }
    
    .calculator-title-container h1 {
        font-size: 2rem;
    }
    
    .calculator-title-container p {
        font-size: 1rem;
    }
    
    .calculator-container {
        padding: 2.5rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .input-grid {
        gap: 2rem;
    }
    
    .summary-cards {
        gap: 1.5rem;
    }
    
    .card-title {
        font-size: 0.875rem;
    }
    
    .card-value {
        font-size: 2rem;
    }
    
    .chart-wrapper {
        height: 350px;
    }
    
    .breakdown-item {
        padding: 1rem 0;
    }
    
    .breakdown-label,
    .breakdown-value {
        font-size: 1rem;
    }
    
    .breakdown-final .breakdown-label {
        font-size: 1.125rem;
    }
    
    .breakdown-final .breakdown-value {
        font-size: 1.5rem;
    }
}

/* Small Mobile (≤ 360px) */
@media (max-width: 360px) {
    .calculator-title-container h1 {
        font-size: 1.25rem;
    }
    
    .calculator-container {
        padding: 1rem;
    }
    
    .card-value {
        font-size: 1.25rem;
    }
    
    .chart-wrapper {
        height: 250px;
        padding: 0.75rem;
    }
    
    .summary-cards {
        gap: 0.75rem;
    }
    
    .summary-card {
        padding: 0.75rem;
    }
}