/* css/arreglemos.css - ARCHIVO UNIFICADO E INDEPENDIENTE */

/* --- 1. Variables y Base --- */
:root {
    --primary: #005F73;      /* Azul Petróleo */
    --primary-dark: #004c5c;
    --secondary: #455A64;    /* Gris Antracita */
    --bg-app: #f0f2f5;       /* Fondo General */
    --white: #ffffff;
    --text-dark: #2c3e50;
    --text-gray: #7f8c8d;
    --border: #e0e0e0;
    --danger: #e74c3c;       /* Rojo más vibrante para deudas */
    --success: #2ecc71;      /* Verde más vibrante para saldos a favor */
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-app);
    margin: 0;
    color: var(--text-dark);
}

/* --- 2. Layout Principal --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.top-bar {
    background: var(--white);
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.logo-top {
    height: 55px;
}

.content-wrapper {
    padding: 30px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--text-dark);
}

.page-header p {
    color: var(--text-gray);
    margin-top: 5px;
}

.text-center { text-align: center; }
.mt-30 { margin-top: 30px; }

/* --- 3. Componentes y Contenedores --- */
.settings-panel {
    background: var(--white);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

.settings-panel select {
    width: auto;
    min-width: 250px;
}

.cliente-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.card-detail {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    overflow: hidden;
}

.highlight {
    border-top: 5px solid var(--primary);
}

.detail-body {
    padding: 25px;
}

.section-title {
    color: var(--primary);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.subsection-title {
    color: var(--text-dark);
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
}

/* --- 4. Formularios y Botones --- */
.form-group-portal {
    margin-bottom: 20px;
}

.flex-input {
    display: flex;
    gap: 10px;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
    background-color: var(--white);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-save {
    background-color: var(--primary);
    color: var(--white);
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    display: inline-block;
}

.btn-save:hover {
    background-color: var(--primary-dark);
}

.btn-add {
    width: auto;
    padding: 12px 20px;
    flex-shrink: 0;
}

.btn-pdf {
    background-color: var(--secondary);
    width: 100%;
}

.btn-pdf:hover {
    background-color: #2c3e50;
}

/* --- 5. Listas de Items --- */
ul { list-style: none; padding: 0; margin: 0; }

.item-list {
    margin: 15px 0 0 0;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 6px;
}

.item-list li {
    background: #f8f9fa;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--secondary);
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.item-list li:hover {
    background: #f1f3f5;
}

.item-list li .delete-btn {
    color: var(--danger);
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 0 5px;
    transition: transform 0.2s;
}

.item-list li .delete-btn:hover {
    transform: scale(1.2);
}

/* --- 6. KPIs y Tablas de Resultados --- */
.card-table {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

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

.kpi-card {
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    border-left: 5px solid gray;
}

.kpi-card.blue { border-left-color: #3498db; }
.kpi-card.green { border-left-color: var(--success); }

.kpi-card h3 { margin: 0; font-size: 1.6rem; color: var(--text-dark); word-break: break-all; }
.kpi-card p { margin: 0; color: var(--text-gray); font-size: 0.9rem; margin-top: 5px; }

/* --- 7. Balances Individuales (NUEVO) --- */
.balances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.balance-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    border: 1px solid #f0f2f5;
    display: flex;
    flex-direction: column;
    position: relative;
}

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

.balance-name {
    font-weight: 700;
    color: var(--text-dark);
    text-transform: uppercase;
    font-size: 0.95rem;
}

.balance-badge {
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 20px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-refund { background: #e8f5e9; color: var(--success); }
.badge-owes { background: #ffebee; color: var(--danger); }
.badge-even { background: #f0f2f5; color: var(--secondary); }

.balance-body {
    margin-bottom: 15px;
}

.balance-label {
    font-size: 0.8rem;
    color: var(--text-gray);
    margin-bottom: 5px;
    display: block;
}

.balance-amount {
    font-size: 1.6rem;
    font-weight: 700;
}

.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }
.amount-zero { color: var(--secondary); }

.balance-footer {
    font-size: 0.85rem;
    color: var(--text-gray);
    border-top: 1px dashed var(--border);
    padding-top: 12px;
    margin-top: auto;
}

/* --- 8. Transferencias --- */
.transfer-item {
    background: var(--white);
    border: 1px solid var(--border);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.transfer-item strong { color: var(--primary); }
.transfer-item .amount { font-weight: bold; color: var(--text-dark); font-size: 1.2rem; }
.transfer-arrow { color: var(--border); font-size: 1.5rem; font-weight: 300; }

.message-box {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
}

/* --- 9. Notificaciones (Toasts) --- */
.notification-area {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--danger);
    color: var(--white);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.3s forwards;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 250px;
}

.toast.success { background-color: var(--success); }
.toast.warning { background-color: #f39c12; color: var(--white); }

.toast-close {
    cursor: pointer;
    margin-left: 15px;
    font-size: 1.2rem;
    opacity: 0.8;
}

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

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

/* --- 10. Responsive --- */
@media (max-width: 768px) {
    .content-wrapper { padding: 15px; }
    .cliente-grid { grid-template-columns: 1fr; }
    .settings-panel { flex-direction: column; text-align: center; gap: 10px; }
    .settings-panel select { width: 100%; }
    .kpi-grid { grid-template-columns: 1fr; }
    .balances-grid { grid-template-columns: 1fr; }
    .transfer-item { flex-direction: column; text-align: center; gap: 10px; }
    .transfer-arrow { transform: rotate(90deg); margin: 5px 0; }
    .notification-area { top: 10px; left: 10px; right: 10px; align-items: center; }
    .toast { width: 100%; box-sizing: border-box; }
}