/* --- IMPORTS & VARIABLES --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Vazirmatn:wght@400;500;700&display=swap');

:root {
    --font-en: 'Inter', sans-serif;
    --font-fa: 'Vazirmatn', sans-serif;
    
    --color-bg: #f4f7f9;
    --color-bg-light: #ffffff;
    --color-text: #2c3e50;
    --color-text-light: #7f8c8d;
    --color-border: #e0e6ed;
    
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-secondary: #9b59b6;
    --color-danger: #e74c3c;
    --color-success: #2ecc71;
    --gradient-primary: linear-gradient(135deg, #3498db, #8e44ad);
    --gradient-board: linear-gradient(135deg, #5dade2, #a569bd);

    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 5px 20px rgba(44, 62, 80, 0.1);
    --border-radius: 12px;
}

/* --- GLOBAL & RESET --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html[dir="ltr"] { font-family: var(--font-en); }
html[dir="rtl"] { font-family: var(--font-fa); }

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- AUTH PAGES --- */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.auth-container {
    background: var(--color-bg-light);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.auth-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 20px;
}
.auth-container h1 {
    margin-bottom: 25px;
    font-weight: 700;
}
.form-group {
    margin-bottom: 20px;
    text-align: start;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9em;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    background-image: var(--gradient-primary);
    color: white;
    font-size: 1.1em;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0,0,0,0.1);
}
.auth-switch {
    margin-top: 25px;
    font-size: 0.9em;
}
.auth-switch a {
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: none;
}
.error-message {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--color-danger);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9em;
}

/* --- HEADER --- */
.main-header {
    background: var(--color-bg-light);
    padding: 0 2rem;
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}
.header-logo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}
.welcome-message {
    font-size: 1.1em;
    font-weight: 500;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.lang-switcher select {
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}
.btn-logout {
    background: var(--color-text-light);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.3s;
}
.btn-logout:hover {
    background: var(--color-text);
}

/* --- MAIN CONTAINER & COLUMNS --- */
.container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    align-items: flex-start;
}
html[dir="rtl"] .container {
    flex-direction: row-reverse;
}
.column {
    background: var(--color-bg-light);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-light);
    display: flex;
    flex-direction: column;
}
.backlog-column {
    flex: 1;
    min-width: 300px;
}
.boards-column {
    flex: 2;
    min-width: 400px;
}
.column h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 700;
}

/* --- FORMS (in-app) --- */
.add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
}
.add-form input[type="text"] {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.add-form input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}
.btn-add, .btn-create {
    padding: 0 20px;
    border: none;
    background-image: var(--gradient-primary);
    color: white;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}
.btn-add:hover, .btn-create:hover {
    transform: scale(1.05);
}

/* --- BOARDS --- */
.boards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.board {
    background-color: var(--color-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 1rem;
    background-image: var(--gradient-board);
    color: white;
    border-radius: 8px;
}
.board-title {
    font-size: 1.2em;
    font-weight: 700;
    padding: 5px;
}
.board-title[contenteditable="true"] {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    outline: none;
}
.board-actions { display: flex; gap: 5px; }
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}
.board-header .icon-btn { color: white; }
.icon-btn:hover { opacity: 1; transform: scale(1.2); }

/* --- TASK ITEMS --- */
.task-list {
    min-height: 80px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.task-item {
    background: var(--color-bg-light);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: box-shadow 0.3s, transform 0.2s;
}
.task-item.sortable-ghost {
    opacity: 0.4;
    background: #c8ebfb;
}
.task-item:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.07);
    transform: translateY(-2px);
}
.task-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.task-text {
    flex-grow: 1;
    transition: color 0.3s, text-decoration 0.3s, opacity 0.3s;
}
html[dir="rtl"] .task-text { text-align: right; }
html[dir="ltr"] .task-text { text-align: left; }
.task-text[contenteditable="true"] {
    background: #f0f0f0;
    padding: 2px 5px;
    border-radius: 4px;
    outline: none;
}
.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--color-text-light);
    opacity: 0.7;
}

.task-actions {
    display: flex;
    gap: 5px;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s;
}
.task-item:hover .task-actions {
    opacity: 1;
}
.task-actions .icon-btn { font-size: 1.1em; color: var(--color-text-light); }
.move-task-btn { display: none; } /* Hidden by default, shown on mobile via JS */
body[data-is-mobile="true"] .move-task-btn { display: block; }

.add-task-to-board-form {
    margin-top: auto;
    padding-top: 1rem;
}
.btn-add-small {
    padding: 0 15px;
    font-size: 1.5em;
    line-height: 1;
    background: var(--color-success);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-add-small:hover { background-color: #27ae60; }

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}
.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    width: 90%;
    max-width: 450px;
    text-align: center;
}
.modal-content h3 { margin-bottom: 1rem; }
.modal-content p { margin-bottom: 2rem; color: var(--color-text-light); }
.modal-content select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    margin-bottom: 2rem;
}
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.btn-secondary {
    background: var(--color-text-light);
    padding: 10px 20px;
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
}
.btn-danger {
    background: var(--color-danger);
    padding: 10px 20px;
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
}
.modal-actions .btn-primary {
    padding: 10px 20px;
    width: auto;
}

/* --- RESPONSIVENESS --- */
@media (max-width: 992px) {
    .container {
        flex-direction: column;
    }
    html[dir="rtl"] .container {
        flex-direction: column; /* Keep it column for mobile */
    }
    .backlog-column, .boards-column {
        width: 100%;
    }
    .header-content { flex-wrap: wrap; height: auto; padding: 10px 0; }
    .header-center { order: 3; width: 100%; text-align: center; padding-top: 10px;}
}
@media (max-width: 768px) {
    .container { padding: 1rem; gap: 1rem; }
    .column { padding: 1rem; }
    .boards-list { grid-template-columns: 1fr; }
    .header-content { justify-content: space-between; }
    .header-center { display: none; }
}