/* ===================================================
   تطبيق حسنات - نظام محاسبة الأعمال اليومية
   تصميم إسلامي هادئ - Mobile First - RTL
   =================================================== */

/* ===== المتغيرات ===== */
:root {
    --primary: #2d8a4e;
    --primary-light: #e8f5e9;
    --primary-dark: #1b5e20;
    --gold: #c9a84c;
    --gold-light: #f5f0e1;
    --bg: #f5f7f5;
    --bg-card: #ffffff;
    --text: #2c3e2c;
    --text-light: #6b7b6b;
    --text-muted: #9ca89c;
    --border: #e0e8e0;
    --shadow: 0 2px 12px rgba(45, 138, 78, 0.08);
    --shadow-lg: 0 8px 30px rgba(45, 138, 78, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Cairo', sans-serif;
    --header-height: 60px;
    --bottom-nav-height: 65px;
    --success: #2d8a4e;
    --danger: #dc3545;
    --warning: #fd7e14;
}

/* ===== الوضع الليلي ===== */
.dark-mode {
    --bg: #1a1f1a;
    --bg-card: #242a24;
    --text: #e0e8e0;
    --text-light: #a0b0a0;
    --text-muted: #6b7b6b;
    --border: #333d33;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --primary-light: #1b3a1b;
    --gold-light: #2a2518;
}

/* ===== إعادة تعيين ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    padding-top: var(--header-height);
    padding-bottom: var(--bottom-nav-height);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
}

/* ===== الشريط العلوي ===== */
.app-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.header-icon {
    font-size: 1.4rem;
    color: var(--gold);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-greeting {
    font-size: 0.85rem;
    color: var(--text-light);
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* نقاط الهيدر */
.header-points {
    background: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.hp-value {
    color: var(--primary);
}

.hp-max {
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== المحتوى الرئيسي ===== */
.main-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== شريط التنقل السفلي ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

.nav-item:hover {
    color: var(--primary);
}

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: 16px 24px;
    font-size: 1.1rem;
    border-radius: var(--radius);
    margin-top: 16px;
}

.btn-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    background: var(--border);
    color: var(--text-light);
}

.btn-mini.btn-save {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-mini.btn-save:hover {
    background: var(--primary);
    color: #fff;
}

.btn-mini.btn-danger {
    background: #fde8e8;
    color: var(--danger);
}

.btn-mini.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-mini.btn-success {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-mini.btn-success:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== التنبيهات ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(45, 138, 78, 0.2);
}

.alert-error {
    background: #fde8e8;
    color: #c62828;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== النماذج ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.form-group label i {
    color: var(--primary);
    margin-left: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 138, 78, 0.1);
}

.form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.form-row {
    display: flex;
    gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* ===== صفحات المصادقة ===== */
.auth-page {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 50%, var(--gold-light) 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 16px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.auth-logo i {
    font-size: 2rem;
    color: #fff;
}

.auth-header h1 {
    font-size: 1.6rem;
    color: var(--primary);
    font-weight: 800;
}

.auth-header p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 4px;
}

.auth-form {
    margin-top: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-footer a {
    font-weight: 700;
}

/* ===== بطاقة نقاط اليوم (Dashboard) ===== */
.today-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: #fff;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.today-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.today-date {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 16px;
}

.today-date i {
    margin-left: 4px;
}

/* دائرة التقدم */
.points-circle {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 12px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--gold);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 327;
    transition: stroke-dashoffset 0.8s ease;
}

.points-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.points-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.points-max {
    font-size: 0.85rem;
    opacity: 0.7;
}

.points-label {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 12px;
}

/* شريط التقدم */
.progress-bar-container {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--gold);
    border-radius: 20px;
    transition: width 0.6s ease;
}

.tasks-done {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    opacity: 0.85;
}

.tasks-percent {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gold);
}

.tasks-count {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}

.completion-badge {
    margin-top: 12px;
    background: var(--gold);
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== بطاقات الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-icon {
    font-size: 1.3rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== الرسم البياني ===== */
.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-header h3 {
    font-size: 0.95rem;
    color: var(--text);
}

.chart-header h3 i {
    color: var(--primary);
    margin-left: 6px;
}

.chart-toggle {
    display: flex;
    gap: 4px;
}

.chart-type-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chart-type-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== صفحة الأعمال ===== */
.top-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.top-progress .progress-bar-container {
    flex: 1;
    background: var(--border);
    height: 10px;
}

.top-progress .progress-bar {
    background: var(--primary);
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 40px;
    text-align: center;
}

/* تصنيف الأعمال */
.task-category {
    margin-bottom: 20px;
}

.category-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 2px solid var(--primary-light);
}

.category-title i {
    margin-left: 6px;
    color: var(--gold);
}

/* بطاقة العمل */
.task-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.task-card.completed {
    border-color: var(--primary);
    background: var(--primary-light);
}

.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.task-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.task-points-badge {
    background: var(--border);
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.3s;
}

.task-points-badge.earned {
    background: var(--primary);
    color: #fff;
}

/* خيارات العمل */
.task-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-btn {
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-btn.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(45, 138, 78, 0.3);
}

.opt-points {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
}

.option-btn.selected .opt-points {
    background: rgba(255, 255, 255, 0.25);
}

.option-clear {
    border-color: var(--danger);
    color: var(--danger);
    padding: 8px 10px;
}

.option-clear:hover {
    background: var(--danger);
    color: #fff;
}

/* حالة فارغة */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    margin-bottom: 16px;
}

/* ===== صفحة الإعدادات ===== */
.settings-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.section-title i {
    margin-left: 6px;
    color: var(--gold);
}

.settings-form {
    margin-top: 12px;
}

/* اختيار اللون */
.color-picker-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    cursor: pointer;
}

.color-option input {
    display: none;
}

.color-swatch {
    display: block;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.color-option input:checked + .color-swatch {
    border-color: var(--text);
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* بطاقة العمل في الإعدادات */
.settings-task-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    margin-bottom: 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.settings-task-card:hover {
    box-shadow: var(--shadow);
}

.task-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
    font-size: 1rem;
}

.task-drag-handle:active {
    cursor: grabbing;
}

.task-details {
    flex: 1;
    min-width: 0;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.task-edit-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.input-inline {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.2s;
}

.input-inline:focus {
    outline: none;
    border-color: var(--primary);
}

.input-sm {
    width: 100px;
}

.input-xs {
    width: 60px;
}

.task-options-list {
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.option-edit-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.add-option-form {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}

/* ===== تأثير السحب والإفلات ===== */
.settings-task-card.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.settings-task-card.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ===== تنبيه الإنجاز ===== */
.achievement-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievement-toast.show {
    transform: translate(-50%, -50%) scale(1);
}

.achievement-toast .icon {
    font-size: 3rem;
    color: var(--gold);
    margin-bottom: 12px;
}

.achievement-toast h3 {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.achievement-toast p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.achievement-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.achievement-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
    .main-content {
        max-width: 640px;
    }

    .stats-grid {
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .form-row {
        flex-direction: column;
    }

    .task-edit-row {
        flex-direction: column;
        align-items: stretch;
    }

    .input-sm, .input-xs {
        width: 100%;
    }

    .option-edit-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ===== أنيميشن عام ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-card, .stat-card, .settings-task-card {
    animation: fadeIn 0.3s ease;
}

/* ===== زخرفة إسلامية خفيفة ===== */
.today-card::after {
    content: '﷽';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    opacity: 0.3;
    white-space: nowrap;
}
