/* =============================================
   IED COFFEE - Gestão de Contratos
   ============================================= */

:root {
    --ied-brown:   #5C3D2E;
    --ied-cream:   #F5F0E8;
    --ied-gold:    #C8A96E;
    --ied-dark:    #2C1810;
    --ied-green:   #3A7D44;
    --ied-red:     #C0392B;
    --ied-orange:  #E67E22;
    --ied-blue:    #2980B9;
    --ied-gray:    #7F8C8D;
    --ied-light:   #FDFCFA;
    --sidebar-w:   250px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--ied-cream);
    color: #333;
    margin: 0;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--ied-dark);
    color: #fff;
    padding: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .3s;
}
.sidebar .brand {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .brand h4 {
    margin: 0;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ied-gold);
    letter-spacing: 1px;
}
.sidebar .brand small {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
    display: block;
    margin-top: 4px;
}
.sidebar nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: .88rem;
    transition: all .2s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: var(--ied-gold);
}
.sidebar nav a i { width: 20px; text-align: center; font-size: 1rem; }

/* MAIN */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 24px 28px;
    min-height: 100vh;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.topbar h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ied-brown);
    margin: 0;
}
.topbar .btn-toggle-sidebar { display: none; }

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    display: flex;
    align-items: center;
    gap: 16px;
}
.kpi-card .kpi-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.kpi-card .kpi-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}
.kpi-card .kpi-info small {
    color: var(--ied-gray);
    font-size: .78rem;
}

/* TABLE CARDS */
.card-section {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: 20px;
}
.card-section h5 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--ied-brown);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* TABLE CUSTOM */
.table-ied {
    font-size: .84rem;
}
.table-ied thead th {
    background: var(--ied-cream);
    color: var(--ied-brown);
    font-weight: 600;
    border-bottom: 2px solid var(--ied-gold);
    white-space: nowrap;
    padding: 8px 10px;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.table-ied td {
    padding: 8px 10px;
    vertical-align: middle;
}
.table-ied tbody tr:hover { background: rgba(200,169,110,.06); }

/* BADGES de STATUS */
.badge-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.badge-ativo    { background: #D5F5E3; color: #1E8449; }
.badge-cancelado{ background: #FADBD8; color: #922B21; }
.badge-suspenso { background: #FEF9E7; color: #B7950B; }

/* Pagamentos - Grid de meses */
.pag-cell {
    cursor: pointer;
    text-align: center;
    min-width: 50px;
    font-size: .68rem;
    font-weight: 600;
    padding: 4px 2px !important;
    border-radius: 3px;
    transition: opacity .15s;
    user-select: none;
}
.pag-cell:hover { opacity: .8; }
.pag-pago             { background: #27AE60; color: #fff; }
.pag-cobranca_enviada { background: #F39C12; color: #fff; }
.pag-em_atraso        { background: #E74C3C; color: #fff; }
.pag-a_vencer         { background: #ECF0F1; color: #7F8C8D; }
.pag-contrato_suspenso{ background: #95A5A6; color: #fff; }
.pag-permuta          { background: #8E44AD; color: #fff; }

/* FORM */
.form-label { font-size: .82rem; font-weight: 600; color: var(--ied-brown); }
.form-control, .form-select {
    font-size: .88rem;
    border-color: #ddd;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ied-gold);
    box-shadow: 0 0 0 .2rem rgba(200,169,110,.25);
}

/* BUTTONS */
.btn-ied {
    background: var(--ied-brown);
    color: #fff;
    border: none;
    font-size: .84rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 6px;
    transition: background .2s;
}
.btn-ied:hover { background: var(--ied-dark); color: #fff; }
.btn-gold {
    background: var(--ied-gold);
    color: var(--ied-dark);
    border: none;
    font-size: .84rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 6px;
}
.btn-gold:hover { background: #b8964f; color: #fff; }

/* MODAL */
.modal-header {
    background: var(--ied-brown);
    color: #fff;
}
.modal-header .btn-close { filter: invert(1); }
.modal-title { font-size: 1rem; font-weight: 600; }

/* Legenda pagamentos */
.legenda-pag {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    font-size: .75rem;
}
.legenda-pag span {
    display: flex;
    align-items: center;
    gap: 5px;
}
.legenda-pag .dot {
    width: 12px; height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 16px; }
    .topbar .btn-toggle-sidebar { display: inline-flex; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* Scroll horizontal tabela pagamentos */
.table-responsive-pag {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* COBRANÇA CARDS */
.cobranca-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border-left: 4px solid #BDC3C7;
    transition: box-shadow .15s;
    gap: 12px;
    flex-wrap: wrap;
}
.cobranca-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.cobranca-pago             { border-left-color: #27AE60; }
.cobranca-cobranca_enviada { border-left-color: #F39C12; }
.cobranca-em_atraso        { border-left-color: #E74C3C; }
.cobranca-a_vencer         { border-left-color: #BDC3C7; }
.cobranca-contrato_suspenso{ border-left-color: #95A5A6; }
.cobranca-permuta          { border-left-color: #8E44AD; }

.cobranca-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 200px;
}
.cobranca-status-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.cobranca-pago .cobranca-status-icon             { background: rgba(39,174,96,.12); color: #27AE60; }
.cobranca-cobranca_enviada .cobranca-status-icon { background: rgba(243,156,18,.12); color: #F39C12; }
.cobranca-em_atraso .cobranca-status-icon        { background: rgba(231,76,60,.12); color: #E74C3C; }
.cobranca-a_vencer .cobranca-status-icon         { background: rgba(189,195,199,.2); color: #7F8C8D; }
.cobranca-contrato_suspenso .cobranca-status-icon{ background: rgba(149,165,166,.15); color: #95A5A6; }
.cobranca-permuta .cobranca-status-icon          { background: rgba(142,68,173,.12); color: #8E44AD; }

.cobranca-info {
    display: flex;
    flex-direction: column;
}
.cobranca-info strong {
    font-size: .92rem;
    color: var(--ied-dark);
}
.cobranca-meta {
    font-size: .75rem;
    color: var(--ied-gray);
    margin-top: 2px;
}
.cobranca-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.cobranca-valor {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ied-brown);
    white-space: nowrap;
}
.cobranca-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.cobranca-status-select {
    font-size: .78rem !important;
    padding: 4px 8px !important;
    width: 150px !important;
    border-radius: 6px;
}

@media (max-width: 640px) {
    .cobranca-card { padding: 12px 14px; }
    .cobranca-right { width: 100%; justify-content: space-between; }
}
