/* ==================================== */
/* 1. پالت رنگی پایه (تم روشن - شاد و پرانرژی) */
/* ==================================== */
:root {
    --color-primary: #6c5ce7;     
    --color-secondary: #00b894;   
    --color-accent: #ff7675;      
    --color-error: #d63031;       
    --bg-page: #f0f3f5;           
    --bg-card: #e5f6ff;           
    --bg-item: #ffffff;           
    --text-dark: #2d3436;         
    --text-muted: #636e72;        
    --shadow-color: rgba(0,0,0,0.15); 
    --input-border: #dcdcdc;
    --completed-bg: #e5f5f0;      
}

/* ==================================== */
/* 2. پالت رنگی تم تاریک (تیره و عمیق‌تر) */
/* ==================================== */
body.dark-mode {
    --color-primary: #b39ddb;       
    --color-secondary: #80cbc4;     
    --color-accent: #ffcc80;        
    --color-error: #ef9a9a;         
    --bg-page: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --bg-card: rgba(30, 30, 30, 0.7);            
    --bg-item: #2c2c2c;             
    --text-dark: #e0e0e0;           
    --text-muted: #b0b0b0;          
    --shadow-color: rgba(0,0,0,0.8); 
    --input-border: #444444;
    --completed-bg: #333333;        
}

/* ==================================== */
/* 3. استایل‌های عمومی */
/* ==================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', sans-serif; 
    transition: background-color 0.4s, color 0.4s, border-color 0.4s, box-shadow 0.4s;
}

html, body {
    width: 100%; 
}

body {
    background: var(--bg-page);
    background-attachment: fixed; /* ثابت نگه داشتن پس‌زمینه موقع اسکرول */
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center; 
    min-height: 100vh;
    padding: 20px 20px;
    color: var(--text-dark);
}

body.en {
    direction: ltr; 
    text-align: left;
    font-family: Arial, sans-serif; 
}

body.en .task-content { margin-right: 15px; margin-left: 0; }
body.en li { border-right: 5px solid var(--text-muted); border-left: none; }
body.en li.completed { border-right-color: var(--color-secondary); }
body.en .actions { direction: ltr; } 
body.en button#add-btn { align-self: flex-start; } 

/* ==================================== */
/* 4. استایل‌های هدر اصلی */
/* ==================================== */
.main-header {
    width: 100%;
    max-width: 900px; 
    margin-left: auto;
    margin-right: auto;
    background: var(--bg-item); 
    padding: 15px 25px;
    border-radius: 18px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--color-secondary);
}

.header-controls {
    display: flex;
    gap: 10px;
}

.header-branding {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-primary); 
}

.header-branding i {
    margin-left: 10px; 
    font-size: 1.2rem;
    color: var(--color-accent); 
}

body.en .header-branding i {
    margin-right: 10px; 
    margin-left: 0;
}

#theme-toggle, #language-toggle {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.3s;
    font-weight: 700;
    display: flex;
    align-items: center;
}

#language-toggle {
    background: var(--color-secondary);
    /*box-shadow: 0 4px 10px rgba(0, 184, 148, 0.4);*/
}
#language-toggle:hover { background: #008f73; }
#theme-toggle:hover { background-color: #5c4fd3; }

body.dark-mode #theme-toggle { 
    background: var(--color-accent); 
    color: var(--bg-card); 
    /*box-shadow: 0 0 5px rgba(255, 204, 128, 0.5);*/ 
}
body.dark-mode #language-toggle { 
    background: var(--color-secondary); 
    color: var(--bg-card); 
    /*box-shadow: 0 0 5px rgba(128, 203, 196, 0.5);*/
}

body.dark-mode #theme-toggle:hover { background: #e0ac5f; }
body.dark-mode #language-toggle:hover { background: #64b5a7; }

/* کارت اصلی (todo-container) */
.todo-container {
    background: var(--bg-card);
    width: 100%;
    max-width: 900px;
    padding: 2.5rem;
    border-radius: 18px;
    box-shadow: 0 10px 30px var(--shadow-color);
    margin-left: auto;
    margin-right: auto;
}

.input-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-item);
    border-radius: 12px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

input[type="text"], textarea {
    width: 100%;
    padding: 20px 25px;
    color: var(--text-dark);
    background: var(--bg-card); 
    border: 1px solid var(--input-border);
    border-radius: 12px;
    font-size: 1.2rem;
    outline: none;
    resize: vertical;
}

input[type="text"]:focus, textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

button#add-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: 0.3s;
    align-self: flex-end;
}

button#add-btn:hover { background-color: #5c4fd3; }

body.dark-mode button#add-btn {
    background-color: var(--color-primary); 
    color: var(--bg-card); 
    /*box-shadow: 0 0 5px rgba(179, 157, 219, 0.5); */
}
body.dark-mode button#add-btn:hover { background-color: #9f8ac8; } 

ul { list-style: none; }

li {
    background: var(--bg-item);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: 0.3s;
    border-left: 5px solid var(--text-muted); 
}

.task-content { flex-grow: 1; margin-left: 15px; }
.task-name { font-size: 1.15rem; font-weight: 700; color: var(--text-dark); line-height: 1.5; }
.task-description { 
    font-size: 0.95rem; /* کمی سایز فونت را بزرگتر کردیم */
    color: var(--text-muted); 
    margin-top: 8px;    /* فاصله از تیتر را کمی بیشتر کردیم */
    max-width: 100%;    /* محدودیت ۹۵ درصد را برداشتیم تا کامل عریض شود */
    line-height: 1.6;   /* فاصله بین خطوط را بیشتر کردیم تا متن‌های طولانی خوانا باشند */
    width: 100%; 
}

.actions { display: flex; gap: 8px; }

.action-btn {
    border: 2px solid transparent; 
    width: 38px; 
    height: 38px; 
    border-radius: 50%; 
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem; 
    transition: 0.2s;
    flex-shrink: 0;
    color: white; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.2); 
}

.delete-btn { background: var(--color-error); }
.complete-btn { background: var(--color-secondary); }
.edit-btn { background: var(--color-accent); }
.save-btn { background: var(--color-primary); }

.delete-btn:hover { background: #af2b2b; }
.complete-btn:hover { background: #008f73; }
.edit-btn:hover { background: #e06a69; }
.save-btn:hover { background: #5c4fd3; }

body.dark-mode .action-btn {
    background: var(--bg-item); 
    border: 2px solid currentColor; 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4); 
}

body.dark-mode .delete-btn { color: var(--color-error); }
body.dark-mode .complete-btn { color: var(--color-secondary); }
body.dark-mode .edit-btn { color: var(--color-accent); }
body.dark-mode .save-btn { color: var(--color-primary); }

body.dark-mode .action-btn:hover { background: #3a3a3a; }

li:not(.editing) .edit-fields, li:not(.editing) .save-btn { display: none; }
li.editing .task-content, li.editing .complete-btn, li.editing .edit-btn { display: none !important; }
li.editing .edit-fields { flex-grow: 1; display: flex; flex-direction: column; gap: 5px; margin-left: 15px; }
li.editing .save-btn { display: flex; }
li.editing .edit-fields input, li.editing .edit-fields textarea { border-color: var(--color-accent); }

body.en li.editing .edit-fields { margin-right: 15px; margin-left: 0; }

/* ==================================== */
/* آیتم تکمیل شده در حالت روشن */
li.completed {
    background-color: #e5f5f0; /* پس‌زمینه سبز روشن */
    border-left-color: #00b894; /* خط کناری سبز */
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.3); /* هاله سبز ملایم */
}

li.completed .task-name {
    text-decoration: line-through;
    color: #2d3436;
}

li.completed .task-description {
    color: #636e72;
}

/* ==================================== */
/* آیتم تکمیل شده در حالت تاریک */
body.dark-mode li.completed {
    background-color: #2a3a2f; /* پس‌زمینه تیره‌تر و سبز مایل */
    border-left-color: #00b894; /* خط کناری روشن سبز */
    opacity: 1;
    box-shadow: 0 0 12px rgba(0, 184, 148, 0.5); /* هاله روشن‌تر */
}

body.dark-mode li.completed .task-name {
    color: #d4f5e0; 
    text-decoration: line-through;
}

body.dark-mode li.completed .task-description {
    color: #a0d9b8; 
}
/*ریسپانسیو*/
@media (max-width: 768px) {

    /*وقتی آیتم  در حالت ویرایش است */
    li.editing .edit-mode {
        display: flex !important;
        flex-direction: column !important; 
        gap: 10px;
    }

    /* دکمه‌ها در یک ردیف افقی */
    li.editing .edit-mode .actions {
        display: flex;
        flex-direction: row;
        justify-content: flex-end;
        gap: 6px;
    }

    li.editing .edit-mode .action-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        font-size: 0.9rem;
    }

    /* ورودی‌ها تمام عرض */
    li.editing .edit-mode input,
    li.editing .edit-mode textarea {
        width: 100%;
        font-size: 16px; /* جلوگیری از زوم موبایل */
        padding: 10px;
    }
}

/* ============================= */
/* Mobile UX Improvements */
/* ============================= */
@media (max-width: 480px) {

    /* ================= Header (همونی که گفتی) ================= */
    .main-header {
        position: relative;
        padding-top: 55px; /* فضا برای دکمه‌های بالا */
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }

    .header-controls {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
        display: flex;
        justify-content: space-between;
        width: calc(100% - 20px);
    }

    #language-toggle,
    #theme-toggle {
        padding: 6px 10px;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    #language-toggle span,
    #theme-toggle span {
        display: none; /* فقط آیکن */
    }

    .header-branding {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .header-branding i {
        font-size: 1rem;
    }

    /* ================= بدنه کلی ================= */
    body {
        padding: 10px;
    }

    /* ================= فرم Add Task ================= */
    .input-form {
        padding: 14px;
        gap: 10px;
        border-radius: 14px;
    }

    input[type="text"],
    textarea {
        font-size: 16px; /* جلوگیری از زوم */
        border-radius: 10px;
    }

    button#add-btn {
        width: 100%;
        align-self: stretch;
        padding: 12px;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* ================= لیست تسک‌ها ================= */
    li {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
        padding: 14px;
        border-radius: 14px;
    }

    .task-name {
        font-size: 1.05rem;
        line-height: 1.4;
    }

    .task-description {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    /* ================= دکمه‌های اکشن ================= */
    .actions {
        justify-content: flex-end;
        gap: 10px;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    /* ================= Edit Mode ================= */
    li.editing {
        border: 2px solid var(--color-primary);
        box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.15);
    }

    li.editing .edit-mode {
        gap: 8px;
    }

    #task-name-input {
        width: 70%;
        height: 42px;         
        min-height: unset;
        padding-top: 8px;
        padding-bottom: 8px;
        line-height: 1.2;
    }

    #task-desc-input {
        min-height: 90px;     
    }
}
