/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #222632;
    --border: #2a2e3b;
    --text: #e4e4e7;
    --text-dim: #8b8fa3;
    --accent: #6c63ff;
    --accent-hover: #5a52e0;
    --green: #22c55e;
    --green-bg: #0d331e;
    --blue: #3b82f6;
    --blue-bg: #0c1f3d;
    --yellow: #eab308;
    --yellow-bg: #332d0a;
    --orange: #f97316;
    --orange-bg: #2d1a0a;
    --red: #ef4444;
    --red-bg: #2d0f0f;
    --purple: #a78bfa;
    --purple-bg: #1e1535;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
header { border-bottom: 1px solid var(--border); padding: 14px 0; margin-bottom: 28px; }
nav { display: flex; align-items: center; gap: 28px; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); }
.logo span { color: var(--accent); }
.nav-links { display: flex; gap: 20px; list-style: none; }
.nav-links a { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.nav-name { color: var(--text-dim); }
.nav-role { padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.role-manager { background: var(--purple-bg); color: var(--purple); }
.role-employee { background: var(--blue-bg); color: var(--blue); }
.nav-logout { color: var(--text-dim); font-size: 13px; }
.nav-logout:hover { color: var(--red); }

/* ===== Flash ===== */
.flash-messages { margin-bottom: 20px; }
.flash { padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 8px; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex;
    align-items: center; gap: 6px; transition: background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.btn-danger { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ===== Auth ===== */
.auth-page { display: flex; justify-content: center; padding-top: 80px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 380px; }
.auth-card h1 { font-size: 24px; margin-bottom: 24px; text-align: center; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-dim); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; font-family: inherit; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-span-2 { grid-column: span 2; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* ===== Dashboard ===== */
.dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.dash-header h1 { font-size: 28px; font-weight: 700; }

.stats-row { display: flex; gap: 12px; margin-bottom: 24px; overflow-x: auto; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 20px; min-width: 100px; text-align: center; }
.stat-number { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; }
.stat-new .stat-number { color: var(--blue); }
.stat-in_progress .stat-number { color: var(--orange); }
.stat-on_hold .stat-number { color: var(--yellow); }
.stat-review .stat-number { color: var(--purple); }
.stat-completed .stat-number { color: var(--green); }

/* ===== Assignments Table ===== */
.assignments-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-bottom: 40px; }
.assignments-table th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.assignments-table td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); }
.assignments-table tr { cursor: pointer; }
.assignments-table tbody tr:hover td { background: var(--bg-hover); }
.code-cell { font-weight: 600; color: var(--accent); white-space: nowrap; }
.title-cell { font-weight: 500; }
.client-tag { font-size: 12px; color: var(--text-dim); margin-left: 8px; }
.date-cell { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* ===== Priority & Status Badges ===== */
.priority-badge, .status-badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.priority-low { background: var(--green-bg); color: var(--green); }
.priority-medium { background: var(--blue-bg); color: var(--blue); }
.priority-high { background: var(--orange-bg); color: var(--orange); }
.priority-urgent { background: var(--red-bg); color: var(--red); }
.status-new { background: var(--blue-bg); color: var(--blue); }
.status-in_progress { background: var(--orange-bg); color: var(--orange); }
.status-on_hold { background: var(--yellow-bg); color: var(--yellow); }
.status-review { background: var(--purple-bg); color: var(--purple); }
.status-completed { background: var(--green-bg); color: var(--green); }

/* ===== Progress Bar ===== */
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.progress-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s; }
.progress-text { font-size: 12px; color: var(--text-dim); margin-left: 6px; }

/* ===== Assignment View ===== */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

.asgn-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.asgn-code { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.asgn-header h1 { font-size: 26px; font-weight: 700; }
.asgn-client { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.asgn-actions { display: flex; gap: 8px; align-items: center; }

.asgn-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; padding-bottom: 40px; }
.asgn-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.asgn-sidebar { display: flex; flex-direction: column; gap: 16px; }

.asgn-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.asgn-card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin-bottom: 12px; }
.asgn-card p { font-size: 14px; line-height: 1.6; }

/* ===== Tasks ===== */
.tasks-section { margin-top: 24px; }
.tasks-section h2 { font-size: 16px; margin-bottom: 12px; }
.task-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.task-input-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 14px; outline: none; }
.task-input-row input:focus { border-color: var(--accent); }
.btn-remove { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-size: 14px; }
.btn-remove:hover { border-color: var(--red); color: var(--red); }

.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.task-item:last-child { border-bottom: none; }
.task-done .task-title { text-decoration: line-through; color: var(--text-dim); }
.task-check-form { display: flex; }
.task-checkbox { width: 20px; height: 20px; border: 2px solid var(--border); border-radius: 4px; background: transparent; cursor: pointer; transition: all 0.15s; }
.task-checkbox:hover { border-color: var(--green); }
.task-checkbox.checked { background: var(--green); border-color: var(--green); }
.task-title { flex: 1; }
.task-date { font-size: 12px; color: var(--text-dim); }

/* ===== Comments ===== */
.comment { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-of-type { border-bottom: none; }
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 13px; }
.comment-header strong { color: var(--text); }
.comment-date { color: var(--text-dim); }
.comment-body { font-size: 14px; line-height: 1.5; }
.comment-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 14px; outline: none; resize: vertical; font-family: inherit; }
.comment-form textarea:focus { border-color: var(--accent); }

/* ===== Sidebar Details ===== */
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-dim); }
.status-select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 14px; outline: none; }

/* History */
.history-item { padding: 6px 0; display: flex; align-items: center; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-meta { color: var(--text-dim); font-size: 12px; }

/* ===== Empty ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.text-dim { color: var(--text-dim); font-size: 14px; }

/* ===== Notification Bell ===== */
.notif-bell {
    color: var(--text-dim);
    font-size: 13px;
    position: relative;
}
.notif-bell:hover { color: var(--text); text-decoration: none; }
.notif-bell.has-unread { color: var(--accent); }
.notif-badge {
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-right: 4px;
}

/* ===== Files / Attachments ===== */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.file-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s;
}
.file-item:hover { border-color: var(--accent); text-decoration: none; }
.file-thumb { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; }
.file-icon {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dim);
}
.file-name { font-size: 12px; color: var(--text); word-break: break-all; }
.file-meta { font-size: 11px; color: var(--text-dim); }

.upload-form { display: flex; gap: 8px; align-items: center; }
.file-input { display: none; }

.comment-files { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.comment-file {
    font-size: 12px;
    padding: 3px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--accent);
}
.comment-file:hover { text-decoration: none; border-color: var(--accent); }

.comment-form-actions { display: flex; gap: 8px; align-items: center; }

/* ===== Activity Feed ===== */
.activity-feed { max-width: 700px; }
.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 7px;
    flex-shrink: 0;
}
.activity-created { background: var(--blue); }
.activity-status_changed { background: var(--orange); }
.activity-commented { background: var(--green); }
.activity-task_completed { background: var(--green); }
.activity-task_uncompleted { background: var(--yellow); }
.activity-file_uploaded { background: var(--purple); }
.activity-edited { background: var(--text-dim); }

.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 14px; line-height: 1.4; }
.activity-detail { color: var(--text-dim); }
.activity-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ===== Notifications Page ===== */
.notif-list { max-width: 600px; }
.notif-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-hover); text-decoration: none; }
.notif-unread { border-left: 3px solid var(--accent); }
.notif-text { font-size: 14px; color: var(--text); flex: 1; }
.notif-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; }

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .report-grid { grid-template-columns: 1fr; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .asgn-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: span 1; }
    .stats-row { flex-wrap: wrap; }
    nav { flex-wrap: wrap; gap: 12px; }
    .nav-user { margin-left: 0; }
}
