/* Image-Based UI Overhaul (Red Theme) */

:root {
    --bg-base: #f3f6fc;
    --bg-surface: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --accent-primary: #e60000;
    --accent-gradient: linear-gradient(135deg, #ff4d4d, #cc0000);
    --border-color: rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.04);
    --shadow-float: 0 10px 25px rgba(230, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-base: #121212;
        --bg-surface: #1e1e1e;
        --text-primary: #f7fafc;
        --text-secondary: #a0aec0;
        --border-color: rgba(255, 255, 255, 0.05);
        --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.3);
        --shadow-float: 0 10px 25px rgba(230, 0, 0, 0.4);
    }
}



* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
input, textarea, button, select { font-family: inherit; }

body {
    background-color: var(--bg-base); color: var(--text-primary);
    font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; padding: 0; overflow-x: hidden;
    user-select: none; -webkit-user-select: none;
}

h1, h2, h3, h4 { font-weight: 800; margin: 0; }

.app-container { min-height: 100vh; position: relative; display: flex; flex-direction: column; }
@media (min-width: 768px) {
    .dashboard-layout { display: grid; grid-template-columns: 240px 1fr; max-width: 1400px; margin: 0 auto; }
    .main-content { min-height: 100vh; border-right: 1px solid var(--border-color); }
}

/* Minimal Header */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2rem 1.5rem 1rem 1.5rem;
}
.header-icon {
    width: 44px; height: 44px; border-radius: 14px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); font-size: 1.4rem; box-shadow: var(--shadow-soft);
    cursor: pointer;
}
.header-title { font-size: 1.4rem; font-weight: 800; }

/* Progress Summary Card */
.progress-card {
    background: var(--accent-gradient); border-radius: 24px; padding: 1.5rem;
    margin: 0 1.5rem 2rem 1.5rem; color: white; box-shadow: var(--shadow-float);
    position: relative; overflow: hidden;
}
.progress-card::after {
    content: ''; position: absolute; right: -20px; top: -20px; width: 100px; height: 100px;
    background: rgba(255,255,255,0.1); border-radius: 50%;
}
.progress-title { font-size: 1.1rem; font-weight: 700; opacity: 0.9; margin-bottom: 4px; }
.progress-subtitle { font-size: 0.9rem; font-weight: 600; opacity: 0.7; margin-bottom: 1.5rem; }

.progress-bar-container { display: flex; align-items: center; gap: 1rem; }
.progress-track {
    flex: 1; height: 8px; background: rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden;
}
.progress-fill { height: 100%; background: white; border-radius: 4px; width: 0%; transition: width 0.6s ease; }
.progress-percent { font-size: 0.9rem; font-weight: 800; }

/* Time Card */
.time-card {
    background: var(--bg-surface); border-radius: 24px; padding: 1.5rem;
    margin: 0 1.5rem 1rem 1.5rem; border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}
.time-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.time-title { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.time-badge { background: rgba(255, 159, 10, 0.1); color: #ff9f0a; padding: 0.4rem 0.8rem; border-radius: 12px; font-size: 0.85rem; font-weight: 800; }
.time-badge.urgent { background: rgba(230,0,0,0.1); color: var(--accent-primary); }
.time-bar-container { margin-bottom: 0.75rem; }
.time-track { width: 100%; height: 8px; background: var(--bg-base); border-radius: 4px; overflow: hidden; }
.time-fill { height: 100%; background: #ff9f0a; border-radius: 4px; transition: width 0.6s ease; }
.time-fill.urgent { background: var(--accent-gradient); }
.time-footer { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); }

/* Section Title */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 1.5rem; margin-bottom: 1rem;
}
.section-title { font-size: 1.2rem; font-weight: 800; }
.see-all { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); text-decoration: none; }

/* Task Cards matching Image */
.task-card {
    background: var(--bg-surface); border-radius: 20px; padding: 1rem; margin: 0 1.5rem 1rem 1.5rem;
    box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 1rem;
    border: 1px solid var(--border-color); transition: all 0.2s ease; cursor: pointer;
}
.task-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0,0,0,0.06); }
.task-card:active { transform: scale(0.98); }

.task-icon-box {
    width: 50px; height: 50px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0;
}
.cat-theme-تصميم { background: rgba(10, 132, 255, 0.1); color: #0a84ff; }
.cat-theme-مونتاج { background: rgba(255, 159, 10, 0.1); color: #ff9f0a; }
.cat-theme-تسويق { background: rgba(48, 209, 88, 0.1); color: #30d158; }
.cat-theme-تصوير { background: rgba(94, 92, 230, 0.1); color: #5e5ce6; }
.cat-theme-مبيعات { background: rgba(255, 55, 95, 0.1); color: #ff375f; }
.cat-theme-عام { background: var(--bg-base); color: var(--text-secondary); }

.task-content { flex: 1; min-width: 0; }
.task-title { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-client { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task-checkbox {
    width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--border-color);
    background: var(--bg-base); display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.task-card.completed .task-checkbox { background: var(--accent-gradient); border-color: transparent; }
.task-card.completed .task-checkbox::after { content: '✓'; color: white; font-weight: 800; font-size: 14px; }
.task-card.completed { opacity: 0.7; }
.task-card.completed .task-title { text-decoration: line-through; }

@media (min-width: 768px) {
    .tasks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin: 0 1.5rem; }
    .task-card { margin: 0; }
}

/* Bottom Nav with Floating Button */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--bg-surface);
    border-top-left-radius: 30px; border-top-right-radius: 30px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.04);
    padding: 0.75rem 0.5rem calc(0.75rem + env(safe-area-inset-bottom)) 0.5rem;
    display: flex; justify-content: space-around; align-items: center;
    z-index: 100;
}
.nav-item {
    color: var(--text-secondary); text-decoration: none;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 0.75rem; font-weight: 700; transition: color 0.3s ease; padding: 0.25rem; flex: 1;
}
.nav-item i { font-size: 1.5rem; }
.nav-item.active { color: var(--accent-primary); }

.fab-container {
    position: relative; top: -35px; /* Pull it up out of the nav */
    display: flex; justify-content: center;
}
.fab {
    width: 64px; height: 64px; border-radius: 50%; background: var(--accent-gradient);
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 2rem; box-shadow: var(--shadow-float); border: none;
    cursor: pointer; transition: transform 0.2s ease; outline: none;
}
.fab i { line-height: 0; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.fab:active { transform: scale(0.9); }

/* Desktop Sidebar Nav overrides */
@media (min-width: 768px) {
    .bottom-nav {
        position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start; align-items: flex-start;
        border-radius: 0; padding: 3rem 1.5rem; border-top: none; box-shadow: none; border-left: 1px solid var(--border-color); background: transparent;
    }
    .nav-item { font-size: 1.2rem; display: flex; align-items: center; gap: 1rem; width: 100%; padding: 1rem; border-radius: 16px; margin-bottom: 0.5rem; }
    .nav-item::after { content: attr(data-tooltip); font-size: 1rem; font-weight: 700; font-family: 'Cairo'; }
    .nav-item.active { background: rgba(230,0,0,0.05); }
    .fab-container { top: 0; width: 100%; margin-top: 2rem; }
    .fab { width: 100%; height: auto; padding: 1rem; border-radius: 16px; font-size: 1.2rem; font-weight: 800; font-family: 'Cairo'; gap: 0.5rem; }
    .fab::after { content: 'إنشاء مهمة'; }
}

/* Modal (Create New Task) */
.modal-backdrop { background-color: rgba(0,0,0,0.4); opacity: 1 !important; display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1040; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-backdrop.show { display: block; }
.premium-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, 150%);
    width: 100%; max-width: 500px; height: 90vh; max-height: 800px;
    background: var(--bg-base); border-radius: 32px 32px 0 0; padding: 2rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom)); z-index: 1050; box-shadow: 0 -10px 40px rgba(0,0,0,0.1); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    overflow-y: auto; display: flex; flex-direction: column;
}
.premium-modal.show { transform: translate(-50%, -50%); height: auto; border-radius: 32px; }
@media (max-width: 767px) {
    .premium-modal { top: auto; bottom: 0; transform: translate(-50%, 100%); width: 100%; height: 85vh; border-radius: 32px 32px 0 0; }
    .premium-modal.show { transform: translate(-50%, 0); }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.modal-back { width: 40px; height: 40px; border-radius: 12px; background: var(--bg-surface); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-primary); cursor: pointer; }
.modal-title { font-size: 1.2rem; font-weight: 800; }

.input-group { margin-bottom: 1.5rem; }
.input-label { display: block; font-size: 1.05rem; font-weight: 800; margin-bottom: 0.75rem; color: var(--text-primary); }
.premium-input {
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 16px; padding: 1rem 1.25rem; width: 100%; font-size: 1rem; font-weight: 600;
}
.premium-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(230,0,0,0.1); }
textarea.premium-input { height: 120px; resize: none; }

.btn-premium {
    background: var(--accent-gradient); color: white; border: none; border-radius: 16px;
    padding: 1.2rem; font-size: 1.1rem; font-weight: 800; width: 100%; cursor: pointer;
    box-shadow: var(--shadow-float); transition: transform 0.2s ease; margin-top: auto;
}
.btn-premium:active { transform: scale(0.96); }

.loading-more { text-align: center; padding: 1rem; color: var(--text-secondary); display: none; font-weight: 700; }
.loading-more.show { display: block; }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-secondary); }

/* Tabs for Single vs Bulk in Modal */
.modal-tabs { display: flex; gap: 0.5rem; background: var(--bg-surface); border-radius: 12px; padding: 0.25rem; margin-bottom: 1.5rem; border: 1px solid var(--border-color); }
.modal-tab { flex: 1; text-align: center; padding: 0.5rem; border-radius: 10px; font-weight: 700; color: var(--text-secondary); border: none; background: none; cursor: pointer; transition: all 0.2s; }
.modal-tab.active { background: var(--accent-gradient); color: white; box-shadow: 0 4px 12px rgba(230,0,0,0.2); }
