/* --- TIME TRACKER PRO: MOBILE FIXED --- */

/* 1. CRITICAL UTILITIES */
.hidden { display: none !important; }

/* 2. THEME VARIABLES */
:root {
    --font-primary: 'Inter', 'IBM Plex Sans Arabic', sans-serif;
    --font-display: 'Poppins', 'IBM Plex Sans Arabic', sans-serif;
    
    --primary-color: #818cf8;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --primary-glow: 0 8px 32px rgba(99, 102, 241, 0.25);
    
    --priority-high: #ff4757;
    --priority-medium: #ffa502;
    --priority-low: #2ed573;
    
    --bg-main: #0f172a;
    --bg-gradient: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #020617 70%);
    
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --card-blur: blur(24px) saturate(180%);
    
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    
    --radius: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-primary); }

body {
    background: var(--bg-main);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    /* Extra padding at bottom for gesture bars */
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
    background-attachment: fixed;
    /* Reset top padding so header can touch the edge */
    padding-top: 0;
}

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* --- HEADER (FIXED FOR STATUS BAR) --- */
.header {
    background: rgba(15, 23, 42, 0.85); /* Slightly darker for better contrast */
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    
    /* THE FIX: Add top padding equal to the Status Bar height + 15px extra space */
    padding-top: calc(15px + env(safe-area-inset-top)); 
    padding-bottom: 15px;
}

.header .container { display: flex; justify-content: space-between; align-items: center; }
.logo { 
    font-size: 24px; 
    font-weight: 800; 
    background: var(--primary-gradient); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    letter-spacing: -0.5px;
}
.lang-toggle { 
    background: rgba(255,255,255,0.05); 
    border: 1px solid rgba(255,255,255,0.1); 
    color: white; padding: 6px 14px; 
    border-radius: 10px; font-weight: 600; 
    cursor: pointer; transition: 0.2s; font-size: 13px;
}
.lang-toggle:hover { background: rgba(255,255,255,0.15); }

/* --- ANALYTICS DASHBOARD --- */
.analytics-section { 
    display: grid; 
    grid-template-columns: 1.5fr 1fr;
    gap: 20px; 
    margin: 30px 0; 
}

.analytics-card { 
    background: var(--glass-bg); 
    backdrop-filter: var(--card-blur);
    border: var(--glass-border);
    border-radius: var(--radius); 
    padding: 25px; 
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.4);
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    height: 160px;
    position: relative;
    overflow: hidden;
}

.time-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
    justify-content: flex-start;
    gap: 25px;
}

.analytics-icon { 
    width: 60px; height: 60px; 
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)); 
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; 
    display: flex; align-items: center; justify-content: center; 
    color: var(--primary-color); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.analytics-info { display: flex; flex-direction: column; }
.analytics-label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.analytics-value { 
    font-size: 48px; 
    font-weight: 700; 
    font-family: var(--font-display); 
    color: white; 
    letter-spacing: -1px;
    text-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* --- TABS --- */
.tabs { 
    display: inline-flex; 
    background: rgba(0,0,0,0.3); 
    padding: 5px; 
    border-radius: 16px; 
    margin: 20px 0 30px 0; 
    border: 1px solid rgba(255,255,255,0.05);
}
.tab-btn { 
    background: transparent; border: none; 
    font-size: 14px; font-weight: 600; color: var(--text-muted); 
    padding: 8px 20px; cursor: pointer; border-radius: 12px;
    transition: 0.3s;
}
.tab-btn:hover { color: white; }
.tab-btn.active { 
    background: var(--primary-gradient); 
    color: white; 
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); 
}

/* --- TASK LIST --- */
.tasks-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.task-card {
    background: var(--glass-bg);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    padding-top: 60px;
    position: relative;
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    overflow: hidden;
}
.task-card:hover { transform: translateY(-6px); border-color: rgba(255,255,255,0.25); background: rgba(40, 50, 70, 0.8); }

.task-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.task-card.priority-high::before { background: var(--priority-high); }
.task-card.priority-medium::before { background: var(--priority-medium); }
.task-card.priority-low::before { background: var(--priority-low); }

.task-title { font-size: 18px; font-weight: 700; margin-bottom: 5px; color: white; }
.task-timer { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.05); }
.timer-text { font-size: 22px; font-weight: 700; font-family: monospace; color: var(--primary-color); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.status-dot.high { color: var(--priority-high); background: currentColor; }
.status-dot.medium { color: var(--priority-medium); background: currentColor; }
.status-dot.low { color: var(--priority-low); background: currentColor; }

.task-actions { position: absolute; top: 15px; right: 15px; display: flex; gap: 8px; z-index: 10; }
[dir="rtl"] .task-actions { right: auto; left: 15px; }

.task-btn { 
    width: 34px; height: 34px; 
    border-radius: 10px; background: rgba(255,255,255,0.05); 
    border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; transition: 0.2s; 
}
.task-btn:hover { background: white; color: black; transform: scale(1.1); }

/* --- MODALS --- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 2000; opacity: 0; visibility: hidden; transition: 0.3s; }
.modal.show { opacity: 1; visibility: visible; }
.modal-content { 
    background: #1e293b; 
    width: 95%; max-width: 420px; 
    border-radius: 30px; 
    border: 1px solid rgba(255,255,255,0.1); 
    box-shadow: 0 25px 60px rgba(0,0,0,0.6); 
    overflow: hidden; 
    transform: scale(0.95); transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
}
.modal.show .modal-content { transform: scale(1); }

.modal-header { padding: 20px 25px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.05); }
.modal-title { font-size: 18px; font-weight: 700; color: white; }
.close-btn { background: rgba(255,255,255,0.05); width: 32px; height: 32px; border-radius: 50%; border: none; color: white; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.close-btn:hover { background: rgba(255,255,255,0.2); }

.modal-body { padding: 25px; }

/* Form Inputs */
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--text-muted); font-weight: 600; }
.form-input, .task-title-field { width: 100%; padding: 14px; background: #0f172a; border: 2px solid transparent; border-radius: 14px; color: white; font-size: 16px; }
.task-title-field { font-size: 24px; font-weight: 800; text-align: center; background: transparent; border-bottom: 2px solid #333; border-radius: 0; padding: 10px; }
.form-input:focus, .task-title-field:focus { outline: none; border-color: var(--primary-color); }
.form-textarea { width: 100%; padding: 14px; background: #0f172a; border: 2px solid transparent; border-radius: 14px; color: white; min-height: 100px; resize: none; }
.form-textarea:focus { outline: none; border-color: var(--primary-color); }

/* Priority Selection */
.priority-options { display: flex; gap: 10px; margin-top: 10px; }
.priority-btn { flex: 1; padding: 12px; background: #0f172a; border: 2px solid transparent; border-radius: 12px; color: var(--text-muted); font-weight: 600; cursor: pointer; transition: 0.2s; }
.priority-btn.selected { background: white; color: black; transform: translateY(-3px); }
.priority-btn.high.selected { background: var(--priority-high); color: white; }
.priority-btn.medium.selected { background: var(--priority-medium); color: black; }
.priority-btn.low.selected { background: var(--priority-low); color: black; }

/* Timer Display */
.timer-display-mobile { 
    background: radial-gradient(circle, #1e1b4b 0%, #0f172a 100%); 
    border: 1px solid rgba(99, 102, 241, 0.3); 
    padding: 30px 0; text-align: center; border-radius: 20px; 
    margin-bottom: 25px; box-shadow: 0 0 30px rgba(99, 102, 241, 0.15); 
}
.timer-mobile { font-size: 56px; font-weight: 800; font-family: monospace; color: white; letter-spacing: 2px; }

/* Timer Controls */
.timer-controls { display: flex; gap: 12px; width: 100%; margin-top: 20px; }
.timer-btn { flex: 1; height: 55px; border-radius: 14px; border: none; font-weight: 700; font-size: 16px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.timer-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.timer-btn.btn-green { background: var(--priority-low); color: #022c22; }
.timer-btn.btn-yellow { background: var(--priority-medium); color: #451a03; }
.timer-btn.btn-red { background: var(--priority-high); color: white; }

/* Reset Button */
.timer-btn.btn-gray { 
    background: rgba(255,255,255,0.1); 
    color: white; 
    font-size: 24px; 
    max-width: 60px; 
    font-family: sans-serif;
}
.timer-btn.btn-gray:hover { background: rgba(255,255,255,0.2); transform: rotate(-90deg); }

.form-actions { display: flex; gap: 12px; margin-top: 25px; }
.btn { flex: 1; padding: 14px; border-radius: 14px; border: none; font-weight: 700; font-size: 16px; cursor: pointer; transition: 0.2s; }
.btn:hover { transform: translateY(-3px); filter: brightness(1.1); }
.btn-cancel { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.btn-green { background: var(--priority-low); color: #022c22; }
.btn-red { background: var(--priority-high); color: white; }

.add-task-btn { 
    position: fixed; bottom: 40px; right: 40px; 
    width: 70px; height: 70px; 
    border-radius: 50%; 
    background: var(--primary-gradient); 
    color: white; border: none; 
    font-size: 40px; 
    box-shadow: 0 10px 30px var(--primary-glow); 
    cursor: pointer; z-index: 100; 
    display: flex; align-items: center; justify-content: center; 
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
    padding-bottom: 5px; 
}
.add-task-btn:hover { transform: scale(1.15) rotate(90deg); box-shadow: 0 15px 40px var(--primary-glow); }
[dir="rtl"] .add-task-btn { right: auto; left: 40px; }

.empty-state { text-align: center; padding: 50px; color: var(--text-muted); border: 2px dashed rgba(255,255,255,0.1); border-radius: 20px; margin-top: 20px; }
.task-card.dragging { opacity: 0.4; transform: scale(0.95); border: 2px dashed var(--primary-color); }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .analytics-section { grid-template-columns: 1fr; }
    .analytics-card { min-width: 100%; height: auto; padding: 20px; }
    .analytics-value { font-size: 40px; }
    .tasks-list { grid-template-columns: 1fr; }
}
