/* ============================================================
   مصاريفي - التصميم الكامل
   ============================================================ */

:root {
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --secondary: #06B6D4;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --dark: #1E293B;
    --text: #334155;
    --text-light: #64748B;
    --border: #E2E8F0;
    --bg: #F7F9FC;
    --soft: #F8FAFC;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 4px 15px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 50px rgba(124,58,237,0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #F0F4FF, #FAF5FF);
    color: var(--text);
    direction: rtl;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    line-height: 1.6;
}

/* AUTH */
.auth-body {
    background: linear-gradient(135deg, #667EEA, #764BA2, #F472B6);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    padding: 20px;
    min-height: 100vh;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.auth-container {
    width: 100%;
    max-width: 440px;
    margin: auto;
}

.auth-header {
    text-align: center;
    color: #fff;
    margin-bottom: 25px;
}

.auth-logo {
    font-size: 4rem;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 4px 20px rgba(0,0,0,0.3));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 5px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.auth-header p {
    font-size: 0.95rem;
    opacity: 0.95;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 30px 25px;
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--dark);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

input, select, textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    outline: none;
    background: var(--soft);
    color: var(--text);
    transition: all 0.3s;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(124,58,237,0.1);
}

input[type="color"] {
    height: 50px;
    padding: 5px;
    cursor: pointer;
}

.pass-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 5px;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    font-weight: 900;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    box-shadow: 0 8px 20px -6px rgba(124,58,237,0.5);
    transition: all 0.2s;
    margin-top: 5px;
}

.submit-btn:hover { transform: translateY(-2px); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-footer p { margin-bottom: 8px; }

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.auth-footer a:hover { text-decoration: underline; }

/* MAIN APP */
.app-container {
    width: 100%;
    max-width: 480px;
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0,0,0,0.1);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 22px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    margin-bottom: 20px;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    position: relative;
    overflow: hidden;
}

.main-header::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 250px; height: 250px;
    background: radial-gradient(circle, rgba(255,255,255,0.15), transparent 70%);
    border-radius: 50%;
}

.user-info { position: relative; z-index: 2; }

.user-info h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 4px;
}

.user-info p {
    font-size: 0.9rem;
    opacity: 0.9;
    direction: ltr;
    text-align: right;
}

.header-actions {
    display: flex;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.icon-btn {
    background: rgba(255,255,255,0.95);
    color: var(--primary);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s;
}

.icon-btn:active { transform: scale(0.9); }

.logout-btn {
    background: rgba(239,68,68,0.95);
    color: #fff;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 0 20px 20px;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 15px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid transparent;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(124,58,237,0.15);
}

.card:active { transform: scale(0.96); }
.card-icon { font-size: 2.5rem; margin-bottom: 10px; }
.card-title { font-weight: 700; font-size: 1rem; }

.action-card {
    background: linear-gradient(135deg, #F8FAFC, #E0E7FF);
    border: 2px solid rgba(124,58,237,0.1);
}

.page-header {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 15px;
}

.back-btn {
    background: var(--soft);
    color: var(--primary);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    cursor: pointer;
    font-size: 1rem;
}

.page-header h1 { font-size: 1.3rem; font-weight: 900; }

.total-banner {
    margin: 0 20px 20px;
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    padding: 18px 22px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    box-shadow: 0 8px 20px -6px rgba(16,185,129,0.4);
}

.total-banner strong { font-size: 1.3rem; font-weight: 900; }

/* HOME TABS */
.home-tabs {
    display: flex;
    gap: 8px;
    padding: 0 20px 20px;
}

.home-tab {
    flex: 1;
    padding: 14px;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.home-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px -6px rgba(124,58,237,0.5);
}

.home-tab-content { display: none; }
.home-tab-content.active { display: block; }

/* MODALS */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
    padding: 28px 24px;
    animation: slideUp 0.35s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.modal-header h2 { font-size: 1.3rem; font-weight: 900; }

.close-btn {
    background: var(--soft);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--soft);
    padding: 5px;
    border-radius: var(--radius-sm);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-weight: 700;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

form { display: flex; flex-direction: column; gap: 14px; }
label { font-weight: 700; font-size: 0.85rem; color: var(--text-light); }

/* LISTS */
.warning-text {
    background: #FEF3C7;
    color: #92400E;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
}

.delete-list { display: flex; flex-direction: column; gap: 10px; }

.delete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: var(--soft);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.delete-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.delete-item-info .emoji { font-size: 1.5rem; }

.delete-action-btn, .edit-action-btn {
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-action-btn { background: var(--danger); }
.edit-action-btn { background: var(--primary); }

/* TRANSACTIONS */
.transactions-list {
    margin: 20px;
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.transactions-list h3 { margin-bottom: 15px; font-weight: 900; }

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background: var(--soft);
    border: 1px solid var(--border);
}

.t-right { display: flex; align-items: center; gap: 12px; flex: 1; }
.t-emoji { font-size: 1.7rem; }
.t-name { font-weight: 700; font-size: 0.95rem; }
.t-date { font-size: 0.75rem; color: var(--text-light); }
.t-note { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.t-amount { font-weight: 900; color: var(--danger); font-size: 1.05rem; }

.installment-info {
    margin-top: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border-radius: 10px;
    border: 1px solid #FED7AA;
}

.installment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: #C2410C;
    margin-bottom: 6px;
}

.progress-bar {
    height: 8px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #FED7AA;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #F97316, #EA580C);
    border-radius: 4px;
}

/* TASKS */
.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 15px;
}

.tasks-header h2 { font-size: 1.2rem; font-weight: 900; }

.add-task-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 50px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px -4px rgba(124,58,237,0.5);
}

.tasks-filter {
    display: flex;
    gap: 6px;
    padding: 0 20px 15px;
    overflow-x: auto;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--soft);
    border: 2px solid var(--border);
    border-radius: 50px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
}

.filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.tasks-list {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border-right: 5px solid var(--primary);
    position: relative;
    transition: all 0.2s;
}

.task-card.done {
    opacity: 0.6;
    border-right-color: var(--success);
}

.task-card.done .task-title {
    text-decoration: line-through;
    color: var(--text-light);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.task-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.task-emoji {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.task-title {
    font-weight: 900;
    font-size: 1.05rem;
    color: var(--dark);
}

.task-freq-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 4px;
}

.freq-daily { background: #DBEAFE; color: #1E40AF; }
.freq-weekly { background: #FEF3C7; color: #92400E; }
.freq-monthly { background: #FCE7F3; color: #9F1239; }
.freq-once { background: #E0E7FF; color: #3730A3; }

.task-check {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}

.task-check:hover { border-color: var(--primary); }

.task-check.checked {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.task-note {
    background: var(--soft);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 10px;
    line-height: 1.6;
}

.task-reminder {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--warning);
    font-weight: 700;
    margin-top: 8px;
    margin-right: 8px;
}

.task-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.task-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 10px;
    border: none;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.task-edit-btn { background: #E0E7FF; color: var(--primary); }
.task-delete-btn { background: #FEE2E2; color: var(--danger); }

/* REPORTS */
.tabs-container {
    display: flex;
    gap: 8px;
    padding: 0 20px 20px;
}

.tabs-container .tab-btn {
    flex: 1;
    padding: 12px;
    background: var(--soft);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-light);
}

.tabs-container .tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.report-tab { display: none; }
.report-tab.active { display: block; }

.month-selector { display: flex; gap: 10px; padding: 0 20px 20px; }
.month-selector select { flex: 1; }
.report-content { padding: 0 20px 20px; }

.report-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.report-card {
    padding: 20px 15px;
    border-radius: var(--radius);
    text-align: center;
    color: #fff;
}

.report-card.expense { background: linear-gradient(135deg, #EF4444, #DC2626); }
.report-card.income { background: linear-gradient(135deg, #10B981, #059669); }
.report-card.balance { background: linear-gradient(135deg, var(--primary), var(--secondary)); grid-column: 1/-1; }

.report-card .label { font-size: 0.85rem; margin-bottom: 8px; opacity: 0.95; }
.report-card .value { font-size: 1.5rem; font-weight: 900; }
.report-card .count { font-size: 0.75rem; opacity: 0.85; margin-top: 5px; }

.report-section {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.report-section h3 { margin-bottom: 15px; font-weight: 900; }

.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.report-row:last-child { border-bottom: none; }

.report-row .info { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.report-row .info .emoji { font-size: 1.4rem; }
.report-row .info .count { font-size: 0.75rem; color: var(--text-light); display: block; }
.report-row .amount { font-weight: 900; color: var(--danger); }

.bar-chart {
    height: 6px;
    background: var(--soft);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.5s;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--dark);
    color: #fff;
    padding: 14px 26px;
    border-radius: 50px;
    font-weight: 700;
    opacity: 0;
    transition: all 0.4s;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 90%;
    text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* LOADING */
.loading, .empty-msg {
    text-align: center;
    color: var(--text-light);
    padding: 30px;
    grid-column: 1/-1;
    font-weight: 700;
}

/* RESPONSIVE */
@media (max-width: 400px) {
    .user-info h1 { font-size: 1.5rem; }
    .card { padding: 20px 12px; }
    .card-icon { font-size: 2.2rem; }
    .form-row { grid-template-columns: 1fr; }
}
