* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
}

body {
    font-family: 'Tajawal', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #f1f5f9; /* رمادي فاتح */
    color: #0f172a;
    line-height: 1.6;
}

/* إطار عام */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: #0f172a; /* أزرق غامق */
    color: #f9fafb;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 700;
}

.app-header .app-subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.app-header .user-badge {
    font-size: 13px;
    background: #0ea5e9;
    padding: 4px 10px;
    border-radius: 999px;
}

.app-main {
    flex: 1;
    padding: 18px;
}

.app-footer {
    text-align: center;
    padding: 10px;
    font-size: 12px;
    color: #6b7280;
}

/* كروت */
.card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.card-header {
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 17px;
    font-weight: 700;
}

.card-header small {
    font-size: 12px;
    color: #6b7280;
}

/* أزرار */
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    background: #2563eb;
    color: #f9fafb;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
}

.button:hover,
button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.button.secondary {
    background: #e5e7eb;
    color: #111827;
}

.button.secondary:hover {
    background: #d1d5db;
}

.button.danger {
    background: #dc2626;
}

.button.danger:hover {
    background: #b91c1c;
}

/* روابط خروج */
.logout-link {
    font-size: 13px;
    color: #f9fafb;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: #1d4ed8;
}

.logout-link:hover {
    background: #ef4444;
}

/* حقول */
input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    border-radius: 6px;
    border: 1px solid #cbd5f5;
    padding: 9px 12px;
    font-size: 14px;
    margin: 6px 0 10px;
    background: #ffffff;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #2563eb;
}

/* نموذج الدخول */
.login-wrapper {
    max-width: 380px;
    margin: 60px auto;
}

.login-title {
    text-align: center;
    margin-bottom: 16px;
}

.login-title h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.login-title p {
    font-size: 13px;
    color: #6b7280;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: #374151;
}

/* رسائل */
.alert {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
}

.alert.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* جدول */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
    background: #ffffff;
}

th,
td {
    padding: 9px 8px;
    text-align: center;
    font-size: 13px;
    border-bottom: 1px solid #e5e7eb;  /* خط أفقي */
    border-right: 1px solid #e5e7eb;   /* خط عمودي بين الأعمدة */
}

th:last-child,
td:last-child {
    border-right: none;
}

th {
    background: #0f172a;
    color: #f9fafb;
    font-weight: 500;
}

/* ألوان الصفوف حسب الحالة (أدمن + يوزر) */
tr.my-in-progress {             /* جاري التنفيذ لليوزر الحالي */
    background: #fff7ed;       /* برتقالي فاتح */
}

tr.new {                        /* جديدة */
    background: #ffffff;       /* أبيض */
}

tr.in_progress {                /* جاري التنفيذ (بشكل عام) */
    background: #fff7ed;       /* برتقالي فاتح مريح */
}

tr.done {                       /* مكتملة */
    background: #ecfdf3;       /* أخضر فاتح جداً */
}

/* نص الحالات داخل عمود الحالة */
td.new {
    color: #0369a1;
    font-weight: 700;
}

td.in_progress {
    color: #c05621;
    font-weight: 700;
}

td.done {
    color: #15803d;
    font-weight: 700;
}

/* التاريخ */
.date-box,
.task-date {
    background-color: #f1f5f9;
    padding: 3px 6px;
    border-radius: 999px;
    font-size: 11px;
    display: inline-block;
    margin-top: 2px;
}

/* مهام */
.task-row {
    cursor: pointer;
    font-weight: 600;
}

/* مؤشر جاري التنفيذ المتحرك */
.progress-pulse {
    margin-top: 3px;
    font-size: 11px;
    color: #fb923c;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.progress-pulse::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #fb923c;
    animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(1.6); opacity: 0.5; }
    100% { transform: scale(1);   opacity: 1; }
}

/* أيقونة ثابتة للحالات (جديد/مكتمل) */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-left: 4px;
}

/* جديد: نقطة زرقاء ثابتة */
.status-dot-new {
    background-color: #0369a1;
}

/* مكتمل: نقطة خضراء ثابتة */
.status-dot-done {
    background-color: #16a34a;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    z-index: 50;
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 480px;
    margin: 10% auto;
    padding: 18px 18px 16px;
    border-radius: 10px;
    position: relative;
}

.modal-content h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.modal-content p {
    font-size: 14px;
    color: #374151;
}

.close {
    position: absolute;
    left: 12px;
    top: 6px;
    cursor: pointer;
    font-size: 22px;
    color: #6b7280;
}

/* شريط فلاتر الأدمن */
.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

/* فلاش للمهام الجديدة */
.new-flash {
    animation: flashRow 1.5s ease-out;
}

@keyframes flashRow {
    0%   { background-color: #fef9c3; }
    100% { background-color: transparent; }
}

/* فلاش خاص لجاري التنفيذ (برتقالى) */
.row-flash-in-progress {
    animation: flashInProgress 1.2s ease-in-out 1;
}

@keyframes flashInProgress {
    0%   { background-color: #f97316; }   /* برتقالى تقيل */
    50%  { background-color: #fed7aa; }   /* برتقالى فاتح */
    100% { background-color: #fff7ed; }   /* نفس لون tr.in_progress */
}

/* فلاش خاص للمكتملة (أخضر) */
.row-flash-done {
    animation: flashDone 1.2s ease-in-out 1;
}

@keyframes flashDone {
    0%   { background-color: #16a34a; }   /* أخضر تقيل */
    50%  { background-color: #bbf7d0; }   /* أخضر فاتح */
    100% { background-color: #ecfdf3; }   /* نفس لون tr.done */
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .app-main {
        padding: 12px;
    }

    .login-wrapper {
        margin: 30px auto;
        padding: 0 10px;
    }

    table {
        min-width: 600px;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 10px 10px 12px;
    }

    th,
    td {
        padding: 7px 5px;
        font-size: 12px;
    }

    .button,
    button {
        padding: 7px 11px;
        font-size: 13px;
    }
}
