/* === Reset & Base === */
@import url('https://fonts.googleapis.com/css2?family=Michroma&family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #eeeef2;
    --white: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #8b8b9e;
    --border: #dddde4;
    --primary: #5b52d4;
    --primary-hover: #4a42c0;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 6px 20px rgba(0,0,0,0.1);
    --font-brand: 'Michroma', 'Microgramma D Extended', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    font-family: var(--font-body);
    background: var(--white);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 16px;
}

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

/* === Navbar === */
.navbar {
    background: var(--white);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-left { display: flex; align-items: center; gap: 14px; }
.nav-logo { height: 48px; width: auto; }
.nav-brand {
    font-family: var(--font-brand);
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 1px;
}
.nav-brand:hover { text-decoration: none; }

.nav-right { display: flex; align-items: center; gap: 24px; }
.nav-user {
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}
.nav-link {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 500;
}
.nav-link:hover { color: var(--primary); }

/* === Date line === */
.date-line {
    padding: 0 32px 16px;
    font-family: var(--font-body);
    font-size: 24px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* === Container === */
.container {
    max-width: 100%;
    margin: 0;
    padding: 0 32px 32px;
}

/* === Flash Messages === */
.flash-messages { padding: 0 32px; margin-bottom: 8px; }
.flash {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 15px;
    margin-bottom: 8px;
}
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* === Auth Pages === */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px;
    background: var(--bg);
}

.auth-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.auth-logo { display: flex; align-items: center; gap: 14px; justify-content: center; margin-bottom: 8px; }
.auth-logo img { height: 48px; }
.auth-logo span {
    font-family: var(--font-brand);
    font-size: 28px;
    color: var(--text);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 4px;
    font-family: var(--font-brand);
    font-size: 28px;
    font-weight: 400;
}
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 28px; font-size: 16px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }

/* === Profile Page === */
.profile-container { max-width: 640px; margin: 24px auto; }
.profile-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}
.profile-card h2 { margin-bottom: 20px; font-size: 20px; font-family: var(--font-brand); }

/* === Forms === */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: var(--font-body);
    background: var(--white);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 82, 212, 0.12);
}

.form-group input:disabled {
    background: var(--bg);
    color: var(--text-secondary);
}

.code-input {
    text-align: center;
    font-size: 28px !important;
    font-family: var(--font-brand) !important;
    letter-spacing: 8px;
    font-weight: 700;
}

.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-body);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-full { width: 100%; padding: 14px 20px; font-size: 16px; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}
.btn-icon:hover { background: var(--bg); }
.btn-danger-icon:hover { color: var(--danger); background: #fef2f2; }
.btn-xs { font-size: 16px; padding: 2px 6px; }

.inline-form { display: inline; }

/* === Dashboard === */
.dashboard-wrap {
    background: var(--bg);
    border-radius: 16px;
    padding: 28px;
    min-height: 70vh;
}

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

.archived-link {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 16px;
}

.dept-columns {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 16px;
    align-items: flex-start;
}

.dept-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
}

.dept-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.dept-header h3 { font-size: 17px; font-weight: 600; }
.dept-actions { display: flex; align-items: center; gap: 4px; }

.badge {
    background: var(--bg);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
}

/* === Task List (Dashboard) === */
.task-list { padding: 10px; }

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--text);
    transition: background 0.1s;
}
.task-item:hover { background: var(--bg); text-decoration: none; }
.task-completed .task-title { text-decoration: line-through; color: var(--text-secondary); }

.task-checkbox { font-size: 20px; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.check-done { color: var(--success); }
.check-progress { color: var(--primary); font-size: 16px; }
.check-open { color: var(--border); }

.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 15px; display: block; font-weight: 500; }
.task-meta { display: flex; gap: 10px; margin-top: 4px; }

.priority { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.priority-high { color: var(--danger); }
.priority-medium { color: var(--warning); }
.priority-low { color: var(--success); }

.due-date { font-size: 13px; color: var(--text-secondary); }

.empty-state { color: var(--text-secondary); font-size: 15px; text-align: center; padding: 28px; }
.empty-dashboard { text-align: center; padding: 80px 20px; color: var(--text-secondary); font-size: 16px; }

/* === Task Detail === */
.back-link { font-size: 15px; color: var(--text-secondary); display: inline-block; margin-bottom: 20px; }
.back-link:hover { color: var(--primary); }

.task-detail { max-width: 1200px; margin: 24px auto; }

.task-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 20px;
    flex-wrap: wrap;
}

.task-detail-title { display: flex; align-items: center; gap: 14px; }
.task-detail-title h2 { font-size: 26px; font-family: var(--font-brand); font-weight: 400; }

.task-detail-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.task-detail-actions select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
}

.badge-open { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #166534; }

.task-detail-body {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 28px;
}

@media (max-width: 900px) {
    .task-detail-body { grid-template-columns: 1fr; }
}

.detail-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.meta-label { display: block; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.meta-value { font-size: 15px; font-weight: 600; }

.detail-description h4 { font-size: 14px; margin-bottom: 6px; color: var(--text-secondary); font-weight: 600; }
.detail-description p { font-size: 15px; white-space: pre-wrap; }

/* === Subtasks === */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-header h3 { font-size: 18px; font-weight: 700; }
.completion-badge { font-size: 13px; color: var(--text-secondary); font-weight: 600; }

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    margin-bottom: 18px;
    overflow: hidden;
}
.progress-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width 0.3s; }

.subtask-list { margin-bottom: 14px; }
.subtask-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.subtask-item:last-child { border-bottom: none; }
.subtask-done .subtask-title { text-decoration: line-through; color: var(--text-secondary); }

.subtask-check {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}
.subtask-done .subtask-check { color: var(--success); }
.subtask-title { flex: 1; font-size: 15px; }

.add-subtask-form { display: flex; gap: 10px; }
.add-subtask-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
.add-subtask-form input:focus { outline: none; border-color: var(--primary); }

/* === Activity Log === */
.task-detail-sidebar .detail-section h3 { margin-bottom: 14px; font-size: 18px; font-weight: 700; }

.comment-form { margin-bottom: 18px; }
.comment-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: var(--font-body);
    resize: vertical;
    margin-bottom: 10px;
}
.comment-form textarea:focus { outline: none; border-color: var(--primary); }

.log-entry {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.log-entry:last-child { border-bottom: none; }
.log-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.log-user { font-size: 14px; font-weight: 700; }
.log-time { font-size: 13px; color: var(--text-secondary); }
.log-content { font-size: 15px; color: var(--text); }

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-sm { max-width: 380px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 20px; font-weight: 700; }

/* === Admin === */
.admin-container { max-width: 960px; margin: 24px auto; }
.admin-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.admin-header h2 { font-size: 24px; margin-top: 10px; font-family: var(--font-brand); font-weight: 400; }

.user-table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.user-table { width: 100%; border-collapse: collapse; }
.user-table th { text-align: left; padding: 14px 20px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); border-bottom: 2px solid var(--border); font-weight: 700; }
.user-table td { padding: 14px 20px; font-size: 15px; border-bottom: 1px solid var(--border); }
.user-table tbody tr:last-child td { border-bottom: none; }
.user-table tbody tr:hover { background: var(--bg); }

.user-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge-admin { background: #ede9fe; color: #6d28d9; }

.text-muted { color: var(--text-secondary); font-size: 14px; }

.form-hint { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; }

/* === Archived === */
.archived-wrap {
    max-width: 960px;
    margin: 24px auto;
}
.archived-wrap h2 {
    font-size: 24px;
    font-family: var(--font-brand);
    font-weight: 400;
    margin-bottom: 20px;
}
.archived-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 24px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.archived-card h3 { font-size: 17px; font-weight: 600; }
.archived-card .task-count { color: var(--text-secondary); font-size: 14px; margin-left: 12px; }

/* === Responsive === */
@media (max-width: 640px) {
    .navbar { padding: 12px 16px; }
    .container { padding: 0 16px 16px; }
    .dashboard-wrap { padding: 16px; border-radius: 12px; }
    .date-line { padding: 0 16px 12px; font-size: 20px; }
    .dept-columns { flex-direction: column; }
    .dept-card { min-width: 100%; max-width: 100%; }
    .task-detail-header { flex-direction: column; }
    .detail-meta { grid-template-columns: 1fr; }
    .user-table-wrap { overflow-x: auto; }
}
