/**
 * DebtManager Modern Stylesheet
 * ----------------------------
 */

:root {
    --bg: #F4F6F8;
    --surface: #FFFFFF;
    --text: #1E293B;
    --subtext: #64748B;
    --border: #E2E8F0;
    --primary: #2563EB;
    --danger: #EF4444;
    --success: #10B981;
    --warning: #F59E0B;
    --card-note: #FEF3C7;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', sans-serif; 
}

body { 
    background: var(--bg); 
    color: var(--text); 
    display: flex; 
    justify-content: center; 
    min-height: 100vh; 
}

/* APP WRAPPER */
.app-container { 
    width: 100%; 
    max-width: 650px; 
    background: var(--surface); 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
    border-left: 1px solid var(--border); 
    border-right: 1px solid var(--border); 
    position: relative; 
}

/* HEADER */
.header { 
    padding: 1rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: var(--surface); 
    position: sticky; 
    top: 0; 
    z-index: 10; 
}

.header h1 { 
    font-size: 1.25rem; 
    font-weight: 700; 
}

/* BUTTONS */
.btn { 
    padding: 0.6rem 1rem; 
    border-radius: 8px; 
    border: none; 
    font-weight: 600; 
    cursor: pointer; 
    display: inline-flex; 
    align-items: center; 
    gap: 0.5rem; 
    font-size: 0.875rem; 
}

.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }

/* VIEWS */
.view { display: none; flex: 1; flex-direction: column; }
.view.active { display: flex; }

/* AUTHENTICATION FORM */
.auth-container { 
    padding: 2rem; 
    display: flex; 
    flex-direction: column; 
    gap: 1rem; 
    justify-content: center; 
    flex: 1; 
}

.input-group { display: flex; flex-direction: column; gap: 0.3rem; }
.input-group label { font-size: 0.8rem; color: var(--subtext); font-weight: 600; }
.input-group input, .input-group textarea { 
    padding: 0.75rem; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    background: var(--bg); 
    color: var(--text); 
    outline: none; 
    font-size: 1rem; 
}

.auth-toggle { font-size: 0.85rem; text-align: center; color: var(--subtext); }

/* DASHBOARD */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; padding: 1rem; }
.summary-card { background: var(--bg); padding: 0.75rem; border-radius: 10px; text-align: center; }
.summary-card div { font-size: 0.75rem; color: var(--subtext); }
.summary-card span { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.controls { padding: 0 1rem 0.5rem; display: flex; gap: 0.5rem; }
.controls input, .controls select { 
    padding: 0.5rem; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    background: var(--bg); 
    color: var(--text); 
    font-size: 0.85rem; 
}
.controls input { flex: 1; }

.customer-list { flex: 1; overflow-y: auto; padding: 0 1rem 5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.customer-card { 
    padding: 0.85rem; 
    border-radius: 10px; 
    border: 1px solid var(--border); 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: var(--surface); 
}
.customer-card:hover { border-color: var(--primary); }

.balance-badge { font-weight: 700; padding: 0.25rem 0.5rem; border-radius: 6px; font-size: 0.85rem; }
.balance-debt { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.balance-paid { background: rgba(16, 185, 129, 0.1); color: var(--success); }

/* CHAT CONVERSATION VIEW */
.chat-sub-header { 
    padding: 0.5rem 1rem; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.chat-history { 
    flex: 1; 
    overflow-y: auto; 
    padding: 1rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.75rem; 
    background: var(--bg); 
}

/* WIDE CHAT CARDS */
.chat-card { 
    width: 95%; /* Make card wide across the screen */
    padding: 1rem; 
    border-radius: 12px; 
    font-size: 0.95rem; 
    position: relative; 
    box-shadow: var(--shadow); 
}

.chat-card.PRODUCT { 
    align-self: flex-start; 
    background: var(--surface); 
    border-left: 5px solid var(--primary); 
}

.chat-card.PAYMENT { 
    align-self: flex-end; 
    background: #ECFDF5; 
    border-right: 5px solid var(--success); 
}

.chat-card.NOTE { 
    align-self: center; 
    background: var(--card-note); 
    border: 1px solid #FCD34D; 
    border-top: 3px solid var(--warning); 
}

.chat-card .date { font-size: 0.7rem; color: var(--subtext); margin-top: 0.5rem; text-align: right; }
.chat-card {
    position: relative;
}

.chat-card .card-actions {
    position: absolute;
    top: 6px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-card .card-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    line-height: 1;
}

.chat-card .card-actions .delete-btn {
    color: var(--danger);
}
.chat-bottom-bar { 
    padding: 0.75rem; 
    background: var(--surface); 
    border-top: 1px solid var(--border); 
    display: flex; 
    gap: 0.5rem; 
    position: sticky; 
    bottom: 0; 
}

.chat-bottom-bar .btn { flex: 1; justify-content: center; }

/* MODALS */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20; justify-content: center; align-items: center; }
.modal.active { display: flex; }
.modal-content { background: var(--surface); padding: 1.5rem; border-radius: 12px; width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 1rem; }

.fab { 
    position: fixed; 
    bottom: 1.5rem; 
    right: calc(50% - 300px + 1.5rem); 
    background: var(--primary); 
    color: white; 
    width: 56px; 
    height: 56px; 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: 1.5rem; 
    border: none; 
    cursor: pointer; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); 
}

@media (max-width: 650px) { 
    .fab { right: 1.5rem; } 
    .chat-card { width: 100%; } 
}