/* ====================================
   CRED SAMPA - PMAE
   Identidade Visual Profissional
   ==================================== */

/* Variáveis de Cores */
:root {
    --primary-blue: #2A4392;
    --primary-orange: #F37021;
    --bg-light: #F0F2F5;
    --text-dark: #333333;
    --text-gray: #555555;
    --white: #FFFFFF;
    --border-light: #E0E4E8;
    --shadow-sm: 0 2px 8px rgba(42, 67, 146, 0.1);
    --shadow-md: 0 4px 16px rgba(42, 67, 146, 0.15);
    --shadow-lg: 0 8px 24px rgba(42, 67, 146, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 16px;
}

/* ====================================
   HEADER
   ==================================== */
header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1e3273 100%);
    color: var(--white);
    padding: 0;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(135deg, transparent 0%, transparent 40%, var(--primary-orange) 40%, var(--primary-orange) 42%, transparent 42%),
        linear-gradient(-45deg, transparent 0%, transparent 58%, var(--primary-orange) 58%, var(--primary-orange) 60%, transparent 60%);
    opacity: 0.15;
    z-index: 0;
}

.header-content {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 30px;
}

.header-text h1 {
    font-size: 2.8em;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.header-text p {
    font-size: 1.3em;
    font-weight: 300;
    opacity: 0.95;
    letter-spacing: 0.3px;
}

/* ====================================
   CONTAINER
   ==================================== */
.container {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 30px;
}

/* ====================================
   FORMULÁRIO
   ==================================== */
#credit-form {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
}

#credit-form h2 {
    color: var(--primary-blue);
    margin-bottom: 30px;
    font-size: 2em;
    font-weight: 700;
    border-bottom: 3px solid var(--primary-orange);
    padding-bottom: 12px;
}

/* Fieldsets Collapsible */
fieldset {
    border: 2px solid var(--border-light);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    background: #FAFBFC;
    transition: all 0.3s ease;
}

fieldset.collapsible {
    cursor: pointer;
}

fieldset.collapsed {
    background: #F5F7FA;
}

fieldset:hover {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

legend {
    font-weight: 600;
    color: var(--primary-blue);
    padding: 0 12px;
    font-size: 1.15em;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    margin: -8px -12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: rgba(42, 67, 146, 0.08);
}

.toggle-icon {
    font-size: 0.85em;
    color: var(--primary-orange);
    transition: transform 0.3s;
    font-weight: bold;
}

.collapsible-content {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 3000px;
    }
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-gray);
    font-size: 0.95em;
}

input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Roboto', sans-serif;
    transition: all 0.3s;
    background: var(--white);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(42, 67, 146, 0.1);
}

input[type="number"]:hover {
    border-color: var(--primary-blue);
}

/* Tooltips */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--primary-orange);
    color: var(--white);
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 6px;
    transition: all 0.2s;
}

.info-icon:hover {
    background: var(--primary-blue);
    transform: scale(1.15);
}

.tooltip-box {
    position: fixed;
    background: var(--text-dark);
    color: var(--white);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.9em;
    max-width: 320px;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    line-height: 1.5;
}

.tooltip-box::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--text-dark);
}

/* Botões de Ação */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 35px;
    padding-top: 25px;
    border-top: 2px solid var(--border-light);
}

button {
    padding: 14px 32px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.3px;
}

button[type="submit"] {
    background: var(--primary-orange);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

button[type="submit"]:hover {
    background: #d95f1a;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button[type="submit"]:active {
    transform: translateY(0);
}

#reset-btn {
    background: var(--white);
    color: var(--text-gray);
    border: 2px solid var(--border-light);
}

#reset-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.toggle-all-btn {
    background: var(--primary-blue);
    color: var(--white);
    padding: 10px 20px;
    font-size: 0.9em;
    box-shadow: var(--shadow-sm);
}

.toggle-all-btn:hover {
    background: #1e3273;
    transform: translateY(-1px);
}

/* Aportes Extras */
#aportes-container {
    margin: 15px 0;
}

.aporte-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.aporte-item input {
    flex: 1;
    min-width: 120px;
}

.aporte-label {
    font-size: 0.9em;
    color: var(--text-gray);
    font-weight: 500;
}

.aporte-mes {
    max-width: 120px;
}

.aporte-valor {
    max-width: 200px;
}

.remove-aporte {
    background: #dc3545;
    color: var(--white);
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
}

.remove-aporte:hover {
    background: #c82333;
    transform: translateY(-1px);
}

#add-aporte {
    background: #28a745;
    color: var(--white);
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 12px;
    font-weight: 500;
}

#add-aporte:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* ====================================
   RESULTADOS
   ==================================== */
#results {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

#results h2 {
    color: var(--primary-blue);
    margin-bottom: 30px;
    font-size: 2em;
    font-weight: 700;
    border-bottom: 3px solid var(--primary-orange);
    padding-bottom: 12px;
}

#loading {
    text-align: center;
    padding: 60px;
    font-size: 1.3em;
    color: var(--primary-blue);
    font-weight: 500;
}

#loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Resumo */
.resumo-container {
    margin-bottom: 35px;
}

.resumo-container h3 {
    color: var(--text-gray);
    margin-bottom: 25px;
    font-size: 1.6em;
    font-weight: 600;
}

.resumo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.resumo-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 24px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-orange);
    transition: all 0.3s;
}

.resumo-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.resumo-item .label {
    font-size: 0.95em;
    color: var(--text-gray);
    margin-bottom: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resumo-item .value {
    font-size: 1.8em;
    color: var(--primary-blue);
    font-weight: 700;
    line-height: 1.2;
}

/* Gráfico */
#chart-output {
    margin-top: 35px;
    min-height: 500px;
    border-radius: 10px;
    overflow: hidden;
}

#error-output {
    margin: 25px 0;
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #721c24;
}

/* ====================================
   TABELAS
   ==================================== */
#tables-section {
    margin-top: 40px;
}

#tables-section h3 {
    color: var(--primary-blue);
    margin: 30px 0 20px 0;
    font-size: 1.6em;
    font-weight: 600;
}

/* Sistema de Abas */
.tabs {
    display: flex;
    gap: 8px;
    margin: 25px 0 0 0;
    border-bottom: 3px solid var(--border-light);
}

.tab-button {
    padding: 14px 28px;
    background: var(--white);
    border: 2px solid var(--border-light);
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-gray);
    transition: all 0.3s;
    font-size: 1em;
}

.tab-button:hover {
    background: var(--bg-light);
    color: var(--primary-blue);
}

.tab-button.active {
    background: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
    position: relative;
    top: 2px;
}

.tab-content {
    display: none;
    padding: 25px 0;
    animation: fadeIn 0.4s;
}

.tab-content.active {
    display: block;
}

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

/* Botões de Download */
.download-buttons {
    margin-bottom: 20px;
    text-align: right;
}

.download-btn {
    background: var(--primary-orange);
    color: var(--white);
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.download-btn:hover {
    background: #d95f1a;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Tabelas de Dados */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 0.95em;
}

.data-table th {
    background: var(--primary-blue);
    color: var(--white);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85em;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-dark);
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
    background-color: #f0f2f5;
}

.separator td {
    text-align: center;
    font-weight: 600;
    color: var(--text-gray);
    padding: 8px !important;
    background: var(--bg-light) !important;
}

/* ====================================
   RESPONSIVIDADE
   ==================================== */
@media (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }
    
    #credit-form, #results {
        padding: 30px;
    }
    
    .resumo-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
        margin: 20px auto;
    }
    
    .header-content {
        padding: 30px 20px;
    }
    
    .header-text h1 {
        font-size: 2em;
    }
    
    .header-text p {
        font-size: 1.1em;
    }
    
    #credit-form, #results {
        padding: 25px;
    }
    
    #credit-form h2, #results h2 {
        font-size: 1.6em;
    }
    
    .resumo-grid {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .aporte-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .aporte-item input {
        max-width: 100%;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .header-text h1 {
        font-size: 1.6em;
    }
    
    .header-text p {
        font-size: 1em;
    }
    
    #credit-form, #results {
        padding: 20px;
    }
    
    .resumo-item .value {
        font-size: 1.5em;
    }
}
