/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Better emoji support */
.tagline {
    font-family: 'Poppins', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

/* Loading animation for AI explanations */
.loading-explanation {
    padding: 20px;
    text-align: center;
    font-style: italic;
    color: #666;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    border-radius: 8px;
    margin: 10px 0;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* EPF RIA Framework Styles */
.ria-tiers-overview {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.tier-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tier-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 4px solid;
}

.tier-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.tier-card.basic {
    border-left-color: #e67e22;
}

.tier-card.adequate {
    border-left-color: #3498db;
}

.tier-card.enhanced {
    border-left-color: #f39c12;
}

.tier-card h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.tier-amount {
    font-size: 1.5em;
    font-weight: 700;
    color: #2c3e50;
    margin: 10px 0;
}

.tier-description {
    color: #7f8c8d;
    font-size: 0.9em;
    line-height: 1.4;
}

.ria-tier-progress {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.tier-progress-bar {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    position: relative;
}

.tier-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tier-progress-name {
    font-weight: 600;
    color: #2c3e50;
}

.tier-progress-amount {
    font-weight: 700;
    color: #27ae60;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 4px;
    transition: width 1s ease-in-out;
}

.tier-status {
    margin-top: 8px;
    font-size: 0.9em;
    font-weight: 500;
}

.tier-status.achieved {
    color: #27ae60;
}

.tier-status.in-progress {
    color: #f39c12;
}

.tier-status.not-started {
    color: #e74c3c;
}


/* Malaysian flag with fallback for desktop */
.malaysia-flag {
    display: inline-block;
    width: 20px;
    height: 14px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAyMCAxNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPCEtLSBNYWxheXNpYW4gRmxhZyAtLT4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSI+CjxyZWN0IHdpZHRoPSIyMCIgaGVpZ2h0PSIxNCIgZmlsbD0iI0ZGRkZGRiIvPgo8IS0tIFJlZCBzdHJpcGVzIC0tPgo8cmVjdCB3aWR0aD0iMjAiIGhlaWdodD0iMSIgZmlsbD0iI0RDMTQzQyIvPgo8cmVjdCB5PSIyIiB3aWR0aD0iMjAiIGhlaWdodD0iMSIgZmlsbD0iI0RDMTQzQyIvPgo8cmVjdCB5PSI0IiB3aWR0aD0iMjAiIGhlaWdodD0iMSIgZmlsbD0iI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SIyMCIgaGVpZ2h0PSIxNCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
    margin-left: 5px;
    font-size: 0; /* Hide the emoji text on desktop */
    text-indent: -9999px; /* Additional fallback to hide text */
}

/* Show emoji on mobile devices that support it */
@media (max-width: 768px) {
    .malaysia-flag {
        background-image: none;
        width: auto;
        height: auto;
        font-size: 1.2em;
        text-indent: 0; /* Reset text hiding on mobile */
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.logo {
    font-size: 3em;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.tagline {
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

/* Navigation */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.tab-btn {
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Calculator Section */
.calculator-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.calculator-section h2 {
    text-align: center;
    font-size: 2.2em;
    color: #333;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Explanation Box */
.explanation-box {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    color: white;
    box-shadow: 0 5px 15px rgba(116, 185, 255, 0.3);
}

.explanation-box h3 {
    font-size: 1.4em;
    margin-bottom: 10px;
    color: #fff;
}

.explanation-box p {
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 1.1em;
}

.input-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: white;
}

.input-group input:focus {
    outline: none;
    border-color: #74b9ff;
    box-shadow: 0 0 10px rgba(116, 185, 255, 0.3);
}

.input-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

/* Calculate Button */
.calculate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(0, 184, 148, 0.4);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 184, 148, 0.6);
}

/* Result Section */
.result-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin-top: 20px;
    border: 2px solid #e9ecef;
}

.result-section h3 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.result-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #74b9ff;
}

.result-card h4 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.result-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #00b894;
    margin: 0;
}

.explanation-result {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    padding: 20px;
    border-radius: 12px;
    color: white;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.explanation-result h4 {
    margin-bottom: 15px;
    font-size: 1.4em;
    font-weight: 600;
    text-align: left;
}

.explanation-result p {
    font-size: 1em;
    line-height: 1.7;
    text-align: left;
}

/* Enhanced styling for LLM-generated content */
.explanation-result h1,
.explanation-result h2,
.explanation-result h3 {
    color: #fff;
    text-align: left;
    margin: 15px 0 10px 0;
    font-weight: 600;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 6px;
}

.explanation-result h1 {
    font-size: 1.6em;
    margin-top: 0;
}

.explanation-result h2 {
    font-size: 1.4em;
}

.explanation-result h3 {
    font-size: 1.2em;
}

.explanation-result strong {
    color: #fff;
    font-weight: 600;
    display: block;
    margin: 12px 0 6px 0;
    font-size: 1.1em;
}

.explanation-result ul,
.explanation-result ol {
    margin: 10px 0;
    padding-left: 20px;
    text-align: left;
}

.explanation-result li {
    margin: 4px 0;
    line-height: 1.5;
    list-style-type: disc;
}

.explanation-result ul li::marker {
    color: rgba(255, 255, 255, 0.8);
}

/* Improved bullet points for better readability */
.explanation-result p:has(br) {
    white-space: pre-line;
}

/* Enhanced styling for sections */
.explanation-result > *:first-child {
    margin-top: 0;
}

.explanation-result > *:last-child {
    margin-bottom: 0;
}

/* Amortization Schedule */
.amortization-schedule {
    margin-top: 20px;
}

.amortization-schedule h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.schedule-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

#scheduleTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#scheduleTable th {
    background: #74b9ff;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
}

#scheduleTable td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

#scheduleTable tr:hover {
    background: #f8f9fa;
}

#scheduleTable tr:nth-child(even) {
    background: #f8f9fa;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .logo {
        font-size: 2.5em;
    }
    
    .nav-tabs {
        flex-direction: column;
        gap: 10px;
    }
    
    .tab-btn {
        padding: 12px 20px;
        font-size: 1em;
    }
    
    .calculator-section {
        padding: 20px;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
    }
    
    .result-value {
        font-size: 1.5em;
    }
    
    .schedule-container {
        font-size: 0.9em;
    }
    
    #scheduleTable th,
    #scheduleTable td {
        padding: 8px 6px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* Success Animation */
.success-animation {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Highlight Animation */
.highlight {
    animation: highlight 1s ease;
}

@keyframes highlight {
    0% { background-color: transparent; }
    50% { background-color: rgba(255, 235, 59, 0.3); }
    100% { background-color: transparent; }
}