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

.cic-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #ffffff;
    color: #111827;
    line-height: 1.5;
    max-width: 100%;
    overflow-x: hidden;
}

/* Title Container */
.cic-title-container {
    background: #2CEC00;
    color: #ffffff;
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cic-title-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.cic-title-container p {
    font-size: 1rem;
    opacity: 0.95;
}

/* Content Layout */
.cic-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
}

/* Input Section */
.cic-input-section {
    margin-bottom: 2rem;
}

.cic-input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

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

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

.cic-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #d1d5db;
    color: #374151;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: help;
    position: relative;
}

.cic-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
}

.cic-input-group input,
.cic-input-group select {
    padding: 0.875rem;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
    min-height: 48px;
    width: 100%;
}

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

.cic-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.25rem;
}

/* Advanced Toggle */
.cic-advanced-toggle {
    margin-bottom: 1.5rem;
}

.cic-toggle-btn {
    width: 100%;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 56px;
}

.cic-toggle-btn:hover {
    border-color: #22c55e;
    background: #f9fafb;
}

.cic-toggle-icon {
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.cic-advanced-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 0.5rem;
    padding: 0;
}

.cic-advanced-content.active {
    max-height: 1000px;
    padding: 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 0.75rem;
}

/* Buttons */
.cic-action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.cic-btn-primary,
.cic-btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 6px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

.cic-btn-primary {
    background: #22c55e;
    color: white;
}

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

.cic-btn-secondary {
    background: #2563eb;
    color: white;
}

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

.cic-loading {
    padding: 1rem;
    background: #f3f4f6;
    border-radius: 6px;
    text-align: center;
    color: #6b7280;
    font-weight: 500;
    display: none;
}

.cic-loading.show {
    display: block;
}

/* Results Section - FIXED */
.cic-results-section {
    animation: fadeIn 0.5s ease-out;
    display: none;
}

.cic-results-section.show {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

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

/* Summary Cards */
.cic-summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.cic-summary-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cic-summary-card h3 {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.cic-summary-amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.25rem;
}

.cic-summary-label {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Progress Bar */
.cic-progress-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

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

.cic-progress-bar {
    height: 1.5rem;
    background: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.cic-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 9999px;
    width: 0%;
    transition: width 1s ease-out;
}

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

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

.cic-chart-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    height: 300px;
    position: relative;
}

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

/* Breakdown Section */
.cic-breakdown-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

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

.cic-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.cic-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.cic-breakdown-table th {
    background: #f9fafb;
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.cic-breakdown-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
}

.cic-breakdown-table tr:hover {
    background: #f9fafb;
}

.cic-breakdown-table tr:last-child td {
    border-bottom: none;
}

.cic-breakdown-table tr:last-child {
    font-weight: bold;
    background: #f0fdf4;
}

/* Results Actions */
.cic-results-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

/* Responsive Design */
@media (min-width: 481px) {
    .cic-title-container {
        padding: 2rem;
    }
    
    .cic-title-container h1 {
        font-size: 2rem;
    }
    
    .cic-content {
        padding: 2rem;
    }
    
    .cic-btn-primary,
    .cic-btn-secondary {
        width: auto;
        min-width: 200px;
    }
}

@media (min-width: 768px) {
    .cic-input-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cic-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cic-charts-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cic-chart-container {
        height: 350px;
    }
    
    .cic-results-actions {
        display: flex;
        justify-content: center;
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .cic-summary-cards {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .cic-chart-container {
        height: 400px;
    }
}

/* Small Mobile Adjustments */
@media (max-width: 360px) {
    .cic-title-container {
        padding: 1.25rem 1rem;
    }
    
    .cic-title-container h1 {
        font-size: 1.5rem;
    }
    
    .cic-content {
        padding: 1.25rem;
    }
    
    .cic-summary-card {
        padding: 1.25rem;
    }
    
    .cic-summary-amount {
        font-size: 1.5rem;
    }
    
    .cic-btn-primary,
    .cic-btn-secondary {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
}

/* Print Styles */
@media print {
    .cic-container {
        background: white;
        color: black;
    }
    
    .cic-title-container {
        background: #2CEC00 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .cic-btn-primary,
    .cic-btn-secondary,
    .cic-toggle-btn,
    .cic-results-actions {
        display: none !important;
    }
    
    .cic-content {
        border: none;
        padding: 0;
    }
    
    .cic-chart-container {
        page-break-inside: avoid;
        height: 250px !important;
    }
}

/* Accessibility */
.cic-input-group input:focus,
.cic-input-group select:focus,
.cic-btn-primary:focus,
.cic-btn-secondary:focus,
.cic-toggle-btn:focus {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

.cic-tooltip:focus {
    outline: 2px solid #2563eb;
}

/* Error Toast */
.cic-error-toast {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    background: #dc2626 !important;
    color: white !important;
    padding: 1rem !important;
    border-radius: 6px !important;
    z-index: 10000 !important;
    max-width: 300px !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Hide scrollbar but allow scrolling */
.cic-table-container::-webkit-scrollbar {
    height: 6px;
}

.cic-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cic-table-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.cic-table-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}