/**
 * Rateio Solar - Estilos
 * Versão 1.0.0
 */

:root {
    --rateio-primary: #248636;
    --rateio-secondary: #1A202C;
    --rateio-tertiary: #2B6CB0;
    --rateio-success: #48bb78;
    --rateio-warning: #ed8936;
    --rateio-danger: #f56565;
    --rateio-info: #4299e1;
    --rateio-light: #f7fafc;
    --rateio-dark: #2d3748;
    --rateio-border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

/* ========================================
   CONTAINER
   ======================================== */

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

/* ========================================
   HERO / HEADER (OCULTAR)
   ======================================== */

.rateio-hero {
    display: none;
}

.rateio-hero-title {
    display: none;
}

.rateio-hero-subtitle {
    display: none;
}

.rateio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.rateio-header-content {
    flex: 1;
}

.rateio-page-title {
    font-size: 28px;
    font-weight: bold;
    color: var(--rateio-secondary);
    margin: 0 0 5px 0;
}

.rateio-page-subtitle {
    font-size: 14px;
    color: #718096;
    margin: 0;
}

/* ========================================
   BREADCRUMB
   ======================================== */

.rateio-breadcrumb {
    margin-bottom: 20px;
}

.rateio-breadcrumb-link {
    color: var(--rateio-tertiary);
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s;
}

.rateio-breadcrumb-link:before {
    content: '←';
    font-size: 16px;
}

.rateio-breadcrumb-link:hover {
    opacity: 0.8;
}

/* ========================================
   CARDS
   ======================================== */

.rateio-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

.rateio-card-header {
    padding: 20px;
    border-bottom: 1px solid var(--rateio-border);
    background: var(--rateio-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rateio-card-header h2,
.rateio-card-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--rateio-secondary);
}

.rateio-card-body {
    padding: 20px;
}

.rateio-card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--rateio-border);
    background: var(--rateio-light);
}

/* ========================================
   GRID DE USINAS
   ======================================== */

.rateio-usinas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.rateio-usina-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.rateio-usina-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.rateio-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--rateio-border);
}

.rateio-info-row:last-child {
    border-bottom: none;
}

.rateio-label {
    font-weight: 600;
    color: var(--rateio-dark);
    font-size: 14px;
}

.rateio-value {
    color: var(--rateio-secondary);
    font-size: 14px;
    text-align: right;
    word-break: break-word;
}

/* ========================================
   BOTÕES (SEM MUDAR COR NO HOVER)
   ======================================== */

.rateio-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: opacity 0.2s;
    line-height: 1.5;
}

.rateio-btn:hover {
    opacity: 0.85;
}

.rateio-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rateio-btn-primary {
    background: var(--rateio-primary);
    color: white;
}

.rateio-btn-primary:hover {
    background: var(--rateio-primary);
    color: white;
}

.rateio-btn-secondary {
    background: var(--rateio-secondary);
    color: white;
}

.rateio-btn-secondary:hover {
    background: var(--rateio-secondary);
    color: white;
}

.rateio-btn-success {
    background: var(--rateio-success);
    color: white;
}

.rateio-btn-success:hover {
    background: var(--rateio-success);
    color: white;
}

.rateio-btn-warning {
    background: var(--rateio-warning);
    color: white;
}

.rateio-btn-warning:hover {
    background: var(--rateio-warning);
    color: white;
}

.rateio-btn-danger {
    background: var(--rateio-danger);
    color: white;
}

.rateio-btn-danger:hover {
    background: var(--rateio-danger);
    color: white;
}

.rateio-btn-info {
    background: var(--rateio-info);
    color: white;
}

.rateio-btn-info:hover {
    background: var(--rateio-info);
    color: white;
}

.rateio-btn-tertiary {
    background: var(--rateio-tertiary);
    color: white;
}

.rateio-btn-tertiary:hover {
    background: var(--rateio-tertiary);
    color: white;
}

.rateio-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.rateio-btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ========================================
   TABELAS (COM SCROLL)
   ======================================== */

.rateio-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    border-radius: 8px;
    border: 1px solid var(--rateio-border);
    position: relative;
}

.rateio-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.rateio-table thead {
    background: var(--rateio-secondary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.rateio-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid var(--rateio-border);
}

.rateio-table td {
    padding: 12px;
    border-bottom: 1px solid var(--rateio-border);
    font-size: 14px;
}

.rateio-table tbody tr:hover {
    background: var(--rateio-light);
}

.rateio-table tbody tr:last-child td {
    border-bottom: none;
}

.rateio-col-actions {
    text-align: center;
    width: 150px;
}

.rateio-col-number {
    text-align: right;
    width: 120px;
}

/* Ocultar coluna Versão */
.rateio-version {
    display: none !important;
}

/* ========================================
   PAGINAÇÃO
   ======================================== */

.rateio-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: white;
    border-top: 1px solid var(--rateio-border);
}

.rateio-pagination button {
    padding: 8px 16px;
    border: 1px solid var(--rateio-border);
    background: white;
    color: var(--rateio-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.rateio-pagination button:hover:not(:disabled) {
    opacity: 0.85;
    background: var(--rateio-light);
}

.rateio-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
}

.rateio-pagination span {
    color: #4a5568;
    font-size: 14px;
}

.rateio-pagination span strong {
    color: var(--rateio-secondary);
    font-weight: 700;
}

/* ========================================
   TABELA EDITÁVEL
   ======================================== */

.rateio-table-editable input[type="number"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--rateio-border);
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
}

.rateio-table-editable input[type="number"]:focus {
    outline: none;
    border-color: var(--rateio-primary);
    box-shadow: 0 0 0 3px rgba(36, 134, 54, 0.1);
}

/* ========================================
   BADGES
   ======================================== */

.rateio-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.rateio-status-rascunho {
    background: #fef5e7;
    color: #b7791f;
}

.rateio-status-verificando {
    background: #e3f2fd;
    color: #1565c0;
}

.rateio-status-aguardando_envio {
    background: #e8f4fd;
    color: #1e429f;
}

.rateio-status-enviado {
    background: #d4edda;
    color: #155724;
}

/* ========================================
   LISTA HEADER
   ======================================== */

.rateio-lista-header {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rateio-lista-info {
    margin-bottom: 20px;
}

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

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

.rateio-meta-label {
    font-size: 12px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
}

.rateio-meta-value {
    font-size: 14px;
    color: var(--rateio-secondary);
    font-weight: 500;
}

.rateio-actions-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.rateio-cliente-count {
    color: #718096;
    font-size: 14px;
    font-weight: normal;
}

/* ========================================
   MODAL (MARGENS CORRIGIDAS)
   ======================================== */

.rateio-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.rateio-modal.active {
    display: flex;
}

.rateio-modal-content {
    background: white;
    border-radius: 8px;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.rateio-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--rateio-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--rateio-light);
}

.rateio-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--rateio-secondary);
}

.rateio-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #718096;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.rateio-modal-close:hover {
    color: var(--rateio-danger);
}

.rateio-modal-body {
    padding: 20px;
}

.rateio-modal-body .rateio-form-group:first-child {
    margin-top: 0;
}

.rateio-modal-body .rateio-form-group:last-child {
    margin-bottom: 0;
}

.rateio-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--rateio-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--rateio-light);
    margin: 0;
}

/* ========================================
   FORM
   ======================================== */

.rateio-form-group {
    margin-bottom: 20px;
}

.rateio-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--rateio-secondary);
    font-size: 14px;
}

.rateio-form-group input,
.rateio-form-group select,
.rateio-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--rateio-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.rateio-form-group input:focus,
.rateio-form-group select:focus,
.rateio-form-group textarea:focus {
    outline: none;
    border-color: var(--rateio-primary);
    box-shadow: 0 0 0 3px rgba(36, 134, 54, 0.1);
}

.rateio-form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.rateio-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

/* ========================================
   SELECT USINAS (ALINHAMENTO CORRIGIDO)
   ======================================== */

#rateio-usina-select {
    background-color: white;
    line-height: 1.5;
    vertical-align: middle;
}

#rateio-usina-select option {
    padding: 8px;
}

/* ========================================
   ALERTAS
   ======================================== */

.rateio-alert {
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid;
    margin-bottom: 15px;
}

.rateio-alert-success {
    background: #d4edda;
    border-color: var(--rateio-success);
    color: #155724;
}

.rateio-alert-warning {
    background: #fff3cd;
    border-color: var(--rateio-warning);
    color: #856404;
}

.rateio-alert-danger {
    background: #f8d7da;
    border-color: var(--rateio-danger);
    color: #721c24;
}

.rateio-alert-info {
    background: #d1ecf1;
    border-color: var(--rateio-info);
    color: #0c5460;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.rateio-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rateio-empty-state h3 {
    color: var(--rateio-secondary);
    margin: 0 0 10px 0;
    font-size: 20px;
}

.rateio-empty-state p {
    color: #718096;
    margin: 0;
    font-size: 14px;
}

/* ========================================
   TOTAIS
   ======================================== */

.rateio-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    background: var(--rateio-light);
    border-radius: 8px;
    margin-top: 20px;
    margin-bottom: 0;
}

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

.rateio-total-label {
    font-size: 12px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
}

.rateio-total-kwh strong,
.rateio-total-percentual strong {
    font-size: 20px;
    font-weight: bold;
    color: var(--rateio-secondary);
}

.rateio-success {
    color: var(--rateio-success) !important;
}

.rateio-error {
    color: var(--rateio-danger) !important;
}

/* ========================================
   LOADING / SPINNER
   ======================================== */

.rateio-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: rateio-spin 0.8s linear infinite;
}

@keyframes rateio-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   PROTOCOLO ELEKTRO (MARGENS CORRIGIDAS)
   ======================================== */

.rateio-protokolo-section {
    margin-top: 20px;
}

.rateio-protokolo-section .rateio-card {
    margin-bottom: 0;
}

.rateio-protokolo-section .rateio-card-body {
    padding: 20px;
}

.rateio-protokolo-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 0;
}

/* ========================================
   CORREÇÕES DE ESPAÇAMENTO
   ======================================== */

/* Remover espaço em branco quando status não é RASCUNHO */
.rateio-card-body:has(.rateio-table-wrapper:not(.rateio-table-editable)) {
    padding-bottom: 0;
}

.rateio-table-wrapper:not(:has(.rateio-table-editable)) {
    margin-bottom: 0 !important;
}

.rateio-table-wrapper + .rateio-totals {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Ajustar espaçamento entre tabela e seções */
.rateio-card:has(.rateio-table-wrapper) + .rateio-protokolo-section {
    margin-top: 20px;
}

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

@media (max-width: 768px) {
    .rateio-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .rateio-usinas-grid {
        grid-template-columns: 1fr;
    }
    
    .rateio-actions-toolbar {
        width: 100%;
    }
    
    .rateio-actions-toolbar .rateio-btn {
        flex: 1;
    }
    
    .rateio-table {
        font-size: 12px;
    }
    
    .rateio-table th,
    .rateio-table td {
        padding: 8px;
    }
    
    .rateio-modal-content {
        width: 95%;
    }
    
    .rateio-page-title {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .rateio-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .rateio-btn-sm {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* ========================================
   ANIMAÇÕES
   ======================================== */

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

.rateio-card {
    animation: fadeIn 0.3s ease-in-out;
}

/* ========================================
   PRINTS
   ======================================== */

@media print {
    .rateio-header,
    .rateio-actions-toolbar,
    .rateio-btn,
    .rateio-breadcrumb {
        display: none;
    }
    
    .rateio-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ========================================
   UTILITIES
   ======================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-10 {
    padding: 10px;
}

.p-20 {
    padding: 20px;
}

.fw-bold {
    font-weight: bold;
}

.fw-normal {
    font-weight: normal;
}
