/* BASE & DARK THEME */
* { box-sizing: border-box; margin:0; padding:0; font-family:'Inter',sans-serif; }
body { background:#1f1f2e; color:#e4e4e7; }
.container { max-width:500px; margin:auto; }
h1 { text-align:center; font-size:1.8rem; margin-bottom:15px; color:#f3f4f6; }

/* NAVIGATION BUTTONS */
.back-btn {
    display:inline-block; background:#4f46e5; color:#fff; padding:10px 18px; border-radius:12px;
    font-weight:600; margin-bottom:15px; cursor:pointer; text-decoration:none;
    transition: background 0.3s;
}
.back-btn:hover { background:#6366f1; }

/* CARDS & CONTAINERS */
.card {
    background:#2c2c3d; border-radius:20px; padding:20px; margin-bottom:20px;
    box-shadow:0 6px 25px rgba(0,0,0,0.4); transition: transform 0.2s;
}
.card h2 { font-size:1.3rem; margin-bottom:15px; color:#f3f4f6; }

/* BALANCE CARD (Home) */
.balance-card {
    background:#2c2c3d; border-radius:16px; padding:15px; margin-bottom:20px;
    display:flex; justify-content:space-between; align-items:center;
    box-shadow:0 6px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.balance-card p { margin:0; font-size:1rem; color:#d1d5db; }
.balance-card p span { font-weight:600; color:#f3f4f6; }
.balance-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

/* USER CARD */
.user-card {
    display:flex; align-items:center; gap:15px;
    background:#2c2c3d; border-radius:20px; padding:20px;
    box-shadow:0 6px 20px rgba(0,0,0,0.4); margin-bottom:15px;
}
.user-card img { width:70px; height:70px; border-radius:50%; object-fit:cover; border:2px solid #4f46e5; }
.user-card p { font-size:1.1rem; font-weight:600; color:#f3f4f6; }

/* LINK WRAPPER */
.card-link { 
    text-decoration: none; 
    position: sticky;
    top: 10px;
    z-index: 99;
    display: block;
}

/* UPLOAD SECTION */
.upload-section input[type="file"] { display:none; }
.upload-label {
    display:block; width:100%; text-align:center;
    background:#4f46e5; color:#fff; padding:14px;
    border-radius:14px; cursor:pointer; font-weight:600; font-size:0.95rem;
    transition: background 0.3s, transform 0.2s;
}
.upload-label:hover { background:#6366f1; transform: translateY(-2px); }

/* IMAGE PREVIEW */
.image-preview {
    height:220px; margin-top:15px; border-radius:16px; 
    background:#1f1f2e; border:2px dashed #4b5563;
    display:flex; align-items:center; justify-content:center;
    color:#9ca3af; overflow:hidden; cursor:pointer;
    transition: border-color 0.3s, background-color 0.3s;
}
.image-preview:hover { border-color:#4f46e5; background-color:#252535; }
.image-preview img { width:100%; height:100%; object-fit:contain; border-radius:16px; }

/* FORM GROUPS */
.form-group { margin-bottom:15px; }
.form-group label { display:block; margin-bottom:6px; font-weight:500; font-size:0.9rem; color:#d1d5db; }
.form-group input {
    width:100%; padding:12px 14px; border-radius:12px; border:1px solid #4b5563;
    background:#1f1f2e; color:#f3f4f6; font-size:0.95rem;
    transition: border 0.3s, box-shadow 0.3s;
}
.form-group select {
    width:100%; padding:12px 14px; border-radius:12px; border:1px solid #4b5563;
    background:#1f1f2e; color:#f3f4f6; font-size:0.95rem;
    transition: border 0.3s, box-shadow 0.3s;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23d1d5db' class='bi bi-chevron-down' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.form-group input:focus, .form-group select:focus {
    border-color:#4f46e5; outline:none; box-shadow:0 0 0 3px rgba(79,70,229,0.3);
}

/* HISTORY & TRANSACTIONS */
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.history-header h2 { margin-bottom: 0; }
.history-header input { width: 160px; padding: 8px 12px; border-radius: 10px; border: 1px solid #4b5563; background: #1f1f2e; color: #f3f4f6; font-size: 0.9rem; }

.upload-count { font-size:0.95rem; color:#d1d5db; font-weight:500; margin-bottom:12px; padding:6px 12px; background:#374151; border-radius:12px; text-align:center; }

.history-card, .transaction-card {
    display:flex; align-items:center; gap:12px; padding:12px; border-radius:14px;
    background:#1f1f2e; margin-bottom:12px; transition: transform 0.2s, background 0.2s;
    border:1px solid #4b5563;
}
.history-card { cursor:pointer; }
.history-card:hover { transform: translateY(-2px); background:#2c2c3d; }
.history-card img { width:60px; height:60px; object-fit:cover; border-radius:12px; flex-shrink:0; }
.transaction-image { cursor: pointer; }
.history-info { flex-grow:1; }
.history-info p, .transaction-card p { margin-bottom:4px; font-size:0.9rem; color:#e4e4e7; }
.history-info p span, .transaction-card p span { font-weight:600; color:#f3f4f6; }

.transaction-card { justify-content:space-between; }

.edit-btn { color:#9ca3af; padding:8px; cursor:pointer; transition:color 0.3s; }
.edit-btn:hover { color:#fff; }

/* MODALS */
.modal {
    display:none; position:fixed; z-index:50; left:0; top:0; width:100%; height:100%;
    overflow:auto; background-color:rgba(0,0,0,0.85); align-items:center; justify-content:center;
}
.modal-content { max-width:90%; max-height:90%; border-radius:16px; overflow:hidden; box-shadow:0 0 25px rgba(0,0,0,0.7); }
.modal-content img { width:100%; height:100%; object-fit:contain; border-radius:16px; }
.modal-close { position:absolute; top:20px; right:20px; font-size:2rem; color:#fff; cursor:pointer; }
.edit-modal-content { background:#2c2c3d; padding:25px; width:90%; max-width:450px; border-radius:16px; position:relative; }

/* FLOATING SAVE BUTTON */
.save-float {
    position:fixed; bottom:25px; right:25px;
    background:#10b981; color:#fff; padding:16px 28px;
    border-radius:50px; font-weight:600; box-shadow:0 8px 25px rgba(0,0,0,0.5);
    cursor:pointer; transition: transform 0.2s, box-shadow 0.3s; z-index:10;
}
.save-float:hover { transform:translateY(-3px); box-shadow:0 12px 28px rgba(0,0,0,0.6); }

/* ACCOUNT PAGE SPECIFIC */
.balance-info { display:flex; justify-content:space-between; align-items:center; margin-bottom:15px; }
.balance-info p { margin:0; font-size:1rem; color:#d1d5db; }
.balance-info p span { font-weight:600; color:#f3f4f6; }

.circular-progress { position: relative; width: 120px; height: 120px; margin:auto; }
.circular-progress svg { transform: rotate(-90deg); }
.circular-progress circle { fill: none; stroke-width:12; stroke-linecap: round; }
.circular-bg { stroke:#4b5563; }
.circular-bar { stroke:#4f46e5; stroke-dasharray: 377; stroke-dashoffset: 377; transition: stroke-dashoffset 0.5s ease; }
.circular-text {
    position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
    font-size:1rem; font-weight:600; color:#f3f4f6; text-align:center;
}

/* MOBILE ADJUSTMENTS */
@media (max-width:400px) {
    .card { padding:18px; }
    .container h1 { font-size:1.5rem; }
    .upload-label { font-size:0.9rem; padding:12px; }
    .save-float { padding:14px 24px; }
    .circular-progress { width:100px; height:100px; }
}

/* ADMIN-SPECIFIC STYLES */
.user-budget-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1f1f2e;
    padding: 15px;
    border-radius: 14px;
    border: 1px solid #4b5563;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}
.user-budget-card .user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}
.user-budget-card .user-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}
.user-budget-card .user-info p { font-weight: 600; color: #f3f4f6; }
.user-budget-card .budget-details { text-align: right; }
.user-budget-card .budget-details p { margin: 2px 0; font-size: 0.95rem; color: #d1d5db; }
.user-budget-card:hover {
    background-color: #2c2c3d;
    transform: translateY(-2px);
}
.user-budget-card.has-pending {
    border-color: #f59e0b; /* Amber border for pending */
    background: #2a2a1f;
}
.pending-badge {
    background: #f59e0b;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

#userList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 15px;
}

/* --- DASHBOARD STYLES --- */
.dashboard-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.dashboard-header .header-actions {
    display: flex;
    gap: 10px;
}
.dashboard-header h1 {
    margin: 0;
    text-align: left;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 20px;
}
.grid-card-user-management { grid-column: 1 / -1; }
.kpi-container {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.kpi-card { text-align: center; }
.kpi-card h4 {
    font-size: 1rem;
    font-weight: 500;
    color: #d1d5db;
    margin-bottom: 10px;
}
.kpi-card p {
    font-size: 2rem;
    font-weight: 700;
    color: #f3f4f6;
}
.grid-card-chart { grid-column: 1 / 2; }
.grid-card-transactions { grid-column: 2 / 4; }
.chart-wrapper {
    position: relative;
    height: 350px; /* Adjust as needed */
}
.table-wrapper {
    max-height: 350px; /* Match chart height */
    overflow-y: auto;
}
.transaction-table {
    width: 100%;
    border-collapse: collapse;
}
.transaction-table th, .transaction-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #4b5563;
}
.transaction-table th {
    font-size: 0.9rem;
    color: #d1d5db;
    font-weight: 600;
}
.transaction-table td {
    font-size: 0.95rem;
}
.transaction-table tbody tr:hover {
    background-color: #374151;
}
.filter-controls { display: flex; align-items: center; gap: 10px; }
.filter-reset-btn {
    padding: 8px 12px; background: #4b5563; color: #fff;
    border: none; border-radius: 8px; cursor: pointer; font-weight: 500;
}
.filter-controls #adminDateFilter {
    width: 300px;
}

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .grid-card-chart, .grid-card-transactions { grid-column: 1 / -1; }
}

/* Modal User Card */
.modal-user-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #1f1f2e;
    padding: 15px;
    border-radius: 14px;
    margin-bottom: 20px;
    border: 1px solid #4b5563;
    cursor: pointer;
    transition: background-color 0.2s;
}
.modal-user-card:hover {
    background-color: #2c2c3d;
    border-color: #6366f1;
}
.modal-user-card img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}
.modal-user-card p { font-size: 1.2rem; font-weight: 600; color: #f3f4f6; }

/* Collapsible Budget Form */
.toggle-budget-btn {
    width: 100%; padding: 12px; background: #374151; color: #f3f4f6;
    border: none; border-radius: 12px; font-weight: 600; cursor: pointer;
    margin-bottom: 20px; transition: background-color 0.3s;
}
.toggle-budget-btn:hover { background-color: #4b5563; }
.budget-form-collapse {
    display: none;
}

/* Scrollbar styles for modal history */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #1f1f2e;
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* LOGIN PAGE */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

/* LIQUIDATION STYLES */
.liquidate-btn {
    width: 100%;
    padding: 12px;
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.3s;
}
.liquidate-btn:hover { background: #d97706; }
.liquidate-btn:disabled { background: #4b5563; cursor: not-allowed; opacity: 0.7; }

.approve-btn { background: #10b981; color: white; border: none; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 0.75rem; margin-left: 10px; }
.approve-btn:hover { background: #059669; }

/* LIVE BACKGROUND FOR LOGIN */
.login-page {
    background: #1f1f2e;
    position: relative;
    min-height: 100vh;
    width: 100%;
    z-index: 0;
    overflow-x: hidden;
}
.login-page::before,
.login-page::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.6;
    animation: moveCircles 20s infinite alternate ease-in-out;
    pointer-events: none;
}
.login-page::before {
    width: 600px; height: 600px; background: #535355;
    top: -200px; left: -200px;
}
.login-page::after {
    width: 500px; height: 500px; background: #243b33;
    bottom: -150px; right: -150px;
    animation-duration: 25s; animation-direction: alternate-reverse;
}
@keyframes moveCircles {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(200px, 100px) scale(1.1); }
    66% { transform: translate(100px, 300px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

/* SPINNER */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* MODAL ANIMATIONS */
@keyframes pulse-success {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes pulse-warning {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
@keyframes pulse-error {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.modal-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0;
}