/**
 * Week-on-Week Debt Reconciliation Panel Styles
 * CRC Brand Theme (Green)
 *
 * @version 1.0.0
 */

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

.reconciliation-container {
    background: linear-gradient(135deg, #1a2a1a 0%, #0d1a0d 100%);
    border: 1px solid #2d4a2d;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.reconciliation-container.collapsed .reconciliation-body {
    display: none;
}

.reconciliation-container.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

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

.reconciliation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3d5a3d;
    cursor: pointer;
    user-select: none;
}

.reconciliation-header:hover {
    opacity: 0.9;
}

.reconciliation-header h3 {
    color: #a0d0a0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapse-icon {
    font-size: 12px;
    color: #70b070;
    transition: transform 0.2s ease;
}

.week-indicator {
    color: #70b070;
    font-size: 13px;
}

.week-indicator span {
    color: #c0e0c0;
}

/* ========================================
   BALANCE FLOW (Opening -> Movements -> Closing)
   ======================================== */

.balance-flow {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.balance-box {
    background: rgba(45, 74, 45, 0.3);
    border: 1px solid #3d5a3d;
    border-radius: 6px;
    padding: 15px 25px;
    text-align: center;
    min-width: 150px;
    flex: 1;
    max-width: 200px;
}

.balance-box .label {
    display: block;
    color: #90b090;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.balance-box .value {
    display: block;
    color: #e0f0e0;
    font-size: 18px;
    font-weight: 600;
}

.balance-box.opening {
    border-left: 3px solid #5a8a5a;
}

.balance-box.closing {
    border-left: 3px solid #80c080;
}

.balance-box.movements .value {
    color: #80c080;
}

.balance-box.movements .value.negative {
    color: #e0a060;
}

.flow-arrow {
    color: #5a8a5a;
    font-size: 20px;
    flex-shrink: 0;
}

/* ========================================
   MOVEMENT BREAKDOWN TABLE
   ======================================== */

.movement-breakdown {
    background: rgba(30, 50, 30, 0.5);
    border: 1px solid #3d5a3d;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    overflow-x: auto;
}

.movement-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 400px;
}

.movement-table th {
    color: #90b090;
    font-size: 11px;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #3d5a3d;
    white-space: nowrap;
}

.movement-table th:not(:first-child) {
    text-align: right;
}

.movement-table td {
    color: #d0e0d0;
    font-size: 13px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(61, 90, 61, 0.5);
}

.movement-table td:not(:first-child) {
    text-align: right;
    font-family: 'Consolas', 'Courier New', monospace;
}

.movement-table .total-row td {
    border-top: 1px solid #5a8a5a;
    border-bottom: none;
    padding-top: 12px;
    font-weight: 600;
}

.movement-table tr:hover {
    background: rgba(61, 90, 61, 0.2);
}

/* Value classes */
.positive {
    color: #80c080 !important;
}

.negative {
    color: #e0a060 !important;
}

.neutral {
    color: #a0a0a0 !important;
}

/* Count badges */
.count-badge {
    display: inline-block;
    background: rgba(80, 120, 80, 0.3);
    color: #90b090;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* ========================================
   RECONCILIATION STATUS
   ======================================== */

.reconciliation-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: rgba(45, 74, 45, 0.3);
    border-radius: 4px;
    flex-wrap: wrap;
}

.reconciliation-status.balanced {
    border-left: 3px solid #60a060;
}

.reconciliation-status.variance {
    border-left: 3px solid #e0a060;
}

.reconciliation-status.first-week {
    border-left: 3px solid #7090b0;
}

.status-icon {
    font-size: 14px;
}

.reconciliation-status.balanced .status-icon {
    color: #60a060;
}

.reconciliation-status.variance .status-icon {
    color: #e0a060;
}

.reconciliation-status.first-week .status-icon {
    color: #7090b0;
}

.status-text {
    color: #b0c0b0;
    font-size: 12px;
}

#recon-result {
    color: #80c080;
    font-weight: 600;
}

.reconciliation-status.variance #recon-result {
    color: #e0a060;
}

.reconciliation-status.first-week #recon-result {
    color: #7090b0;
}

.variance-info {
    margin-left: auto;
    color: #e0a060;
    font-size: 11px;
}

/* ========================================
   FORMULA DISPLAY
   ======================================== */

.formula-display {
    margin-top: 10px;
    padding: 10px;
    background: rgba(20, 35, 20, 0.5);
    border: 1px dashed #3d5a3d;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    color: #90a090;
    overflow-x: auto;
}

.formula-display .formula-label {
    color: #70b070;
    margin-bottom: 5px;
}

.formula-display .formula-values {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.formula-display .formula-item {
    white-space: nowrap;
}

.formula-display .formula-operator {
    color: #60a060;
    font-weight: bold;
}

/* ========================================
   FIRST WEEK MESSAGE
   ======================================== */

.first-week-message {
    text-align: center;
    padding: 30px;
    color: #90a090;
}

.first-week-message .icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.first-week-message .title {
    font-size: 14px;
    font-weight: 600;
    color: #a0b0a0;
    margin-bottom: 5px;
}

.first-week-message .subtitle {
    font-size: 12px;
    color: #708070;
}

/* ========================================
   LOADING STATE
   ======================================== */

.reconciliation-loading {
    text-align: center;
    padding: 40px;
    color: #90a090;
}

.reconciliation-loading .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #3d5a3d;
    border-top: 2px solid #80c080;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@media (max-width: 768px) {
    .balance-flow {
        flex-direction: column;
        gap: 10px;
    }

    .balance-box {
        width: 100%;
        max-width: none;
    }

    .flow-arrow {
        transform: rotate(90deg);
    }

    .reconciliation-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .variance-info {
        margin-left: 0;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .reconciliation-container {
        background: white;
        border: 1px solid #ccc;
        color: black;
        page-break-inside: avoid;
    }

    .reconciliation-header h3,
    .balance-box .label,
    .movement-table th {
        color: #333;
    }

    .balance-box .value,
    .movement-table td {
        color: #000;
    }

    .positive {
        color: #008000 !important;
    }

    .negative {
        color: #cc6600 !important;
    }
}
