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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container styles - responsive height for iframe vs new tab */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto 1fr auto;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

/* Detect if opened in new tab (larger viewport) */
@media (min-height: 600px) {
    .container {
        height: 90vh;
        padding: 20px;
        gap: 15px;
    }
}

/* Credit Card Dashboard */
.card-dashboard {
    grid-column: 1 / 3;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 12px;
    padding: 15px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.credit-card {
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header h3 {
    font-size: 1.2em;
    font-weight: 600;
}

.card-limit {
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-limit select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    padding: 5px;
    font-size: 0.9em;
}

.card-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.label {
    font-size: 0.8em;
    opacity: 0.8;
}

.value {
    font-size: 1.1em;
    font-weight: 600;
}

/* Purchase Section */
.purchase-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.purchase-section h4 {
    margin-bottom: 10px;
    color: #2a5298;
    font-size: 1em;
}

.purchase-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.purchase-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch-friendly */
}

.purchase-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.purchase-btn:active {
    transform: translateY(0);
}

.custom-purchase {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.custom-purchase input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.custom-purchase button {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
    min-height: 44px;
}

/* Payment Section */
.payment-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.payment-section h4 {
    margin-bottom: 10px;
    color: #2a5298;
    font-size: 1em;
}

.payment-slider-container {
    margin-bottom: 15px;
}

.payment-slider-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9em;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    margin-bottom: 10px;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.payment-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.payment-option-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
}

.payment-option-btn:hover {
    background: #e9ecef;
}

.payment-option-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.make-payment-btn {
    width: 100%;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.make-payment-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Visualization Section */
.visualization-section {
    grid-column: 1 / 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.chart-container, .comparison-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chart-container h4, .comparison-container h4 {
    margin-bottom: 10px;
    color: #2a5298;
    font-size: 1em;
}

#balanceChart {
    width: 100%;
    height: 150px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.comparison-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.comparison-card {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.comparison-card h5 {
    font-size: 0.9em;
    margin-bottom: 8px;
    color: #666;
}

.comparison-value {
    font-size: 1.1em;
    font-weight: 600;
    color: #2a5298;
    margin-bottom: 4px;
}

.comparison-time {
    font-size: 0.8em;
    color: #666;
}

.comparison-card.highlight {
    border-color: #dc3545;
    background: #fff5f5;
}

/* What-if and Summary Sections */
.whatif-section, .summary-section {
    grid-column: 1 / 3;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.whatif-section h4, .summary-section h4 {
    margin-bottom: 10px;
    color: #2a5298;
    font-size: 1em;
}

.whatif-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.whatif-controls select, .whatif-controls button {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 0.9em;
    min-height: 36px;
}

.whatif-controls button {
    background: #667eea;
    color: white;
    border-color: #667eea;
    cursor: pointer;
}

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

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.summary-label {
    font-weight: 500;
}

.summary-value {
    font-weight: 600;
    color: #2a5298;
}

.reflection-questions {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #2196f3;
}

/* Control Buttons */
.control-buttons {
    grid-column: 1 / 3;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.control-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.control-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8em;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    word-wrap: break-word;
}

.tooltip.show {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover {
    color: black;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        padding: 8px;
        gap: 8px;
    }
    
    .visualization-section {
        grid-column: 1;
        grid-template-columns: 1fr;
    }
    
    .whatif-section, .summary-section, .control-buttons {
        grid-column: 1;
    }
    
    .purchase-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .comparison-cards {
        grid-template-columns: 1fr;
    }
    
    .whatif-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-buttons {
        flex-direction: column;
    }
}

/* Animation classes */
.pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.highlight {
    background: #fff3cd !important;
    border: 2px solid #ffc107 !important;
}

/* Accessibility improvements */
button:focus, input:focus, select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .container {
        height: auto;
        box-shadow: none;
    }
    
    button {
        display: none;
    }
}