/* ═══════════════════════════════════════════
   ProjectFlow — Stylesheet
   (c) southlab.eu
   ═══════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f1f5f9;
    --card-bg: #fff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
    --radius: 12px;
    --radius-sm: 8px;
    --bg-alt: #f8fafc;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

/* ─── Navigation ──────────────────────────── */
nav {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
}
.nav-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    margin-right: 2rem;
    text-decoration: none;
    white-space: nowrap;
}
.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1;
}
.nav-links > li > a,
.nav-drop-btn {
    color: #cbd5e1;
    padding: .5rem .85rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.nav-links > li > a:hover,
.nav-drop-btn:hover,
.nav-links > li > a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    text-decoration: none;
}
.open-group > .nav-drop-btn { color: #fff; }

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: .4rem 0;
    list-style: none;
    z-index: 200;
}
.nav-dropdown.is-open .nav-submenu { display: block; }
.nav-submenu a {
    display: block;
    padding: .55rem 1rem;
    color: var(--text);
    font-size: .85rem;
    text-decoration: none;
}
.nav-submenu a:hover { background: var(--border-light); }
.nav-submenu a.active { color: var(--primary); font-weight: 600; background: #eff6ff; }

/* Mobile nav */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}
.nav-backdrop.show { display: block; }

/* Nav user section */
.nav-user-section {
    display: flex;
    align-items: center;
    gap: .5rem;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: fixed;
        top: 0; right: 0;
        width: 260px;
        height: 100vh;
        background: #1e293b;
        flex-direction: column;
        padding: 1.5rem;
        gap: .2rem;
        z-index: 200;
        overflow-y: auto;
    }
    .nav-links.show { display: flex; }
    .nav-submenu {
        position: static;
        box-shadow: none;
        background: rgba(255,255,255,.05);
        border-radius: var(--radius-sm);
    }
    .nav-submenu a { color: #cbd5e1; }
    .nav-submenu a:hover { background: rgba(255,255,255,.1); }
    .nav-submenu a.active { background: rgba(37,99,235,.2); color: #93c5fd; }
    .nav-user-section {
        margin-left: 0 !important;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255,255,255,.1);
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─── Container ───────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ─── Page Header ─────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: .88rem; margin-top: .15rem; }

/* ─── Cards ───────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}
.card-title { font-weight: 600; font-size: .95rem; }
.card-body { padding: 1.25rem; }

/* ─── Stat Cards ──────────────────────────── */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1.25rem;
    text-align: center;
}
.stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .3px; font-weight: 500; }

/* ─── Buttons ─────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .1s;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: .95rem; }

/* ─── Forms ───────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ─── Tables ──────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: .7rem 1rem;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
tbody td {
    padding: .7rem 1rem;
    font-size: .85rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }

/* ─── Badges ──────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-green { background: #f0fdf4; color: #16a34a; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-orange { background: #fff7ed; color: #ea580c; }

/* Status badges */
.status-new { background: #eff6ff; color: #2563eb; }
.status-in_progress { background: #fffbeb; color: #d97706; }
.status-done { background: #f0fdf4; color: #16a34a; }
.status-on_hold { background: #f1f5f9; color: #64748b; }
.status-cancelled { background: #fef2f2; color: #ef4444; }

/* Priority badges */
.priority-low { background: #f1f5f9; color: #64748b; }
.priority-medium { background: #eff6ff; color: #2563eb; }
.priority-high { background: #fffbeb; color: #d97706; }
.priority-urgent { background: #fef2f2; color: #ef4444; }

/* ─── Alerts ──────────────────────────────── */
.alert {
    padding: .8rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    border-left: 4px solid transparent;
    margin-bottom: 1rem;
}
.alert-success { background: #f0fdf4; color: #166534; border-left-color: var(--success); }
.alert-error { background: #fef2f2; color: #991b1b; border-left-color: var(--danger); }
.alert-warning { background: #fffbeb; color: #92400e; border-left-color: var(--warning); }
.alert-info { background: #eff6ff; color: #1e40af; border-left-color: var(--info); }

/* ─── Progress Bar ────────────────────────── */
.progress-bar {
    background: var(--border-light);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
    width: 100%;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width .3s ease;
}

/* ─── Pagination ──────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: .3rem;
    padding: 1rem;
}
.pagination button {
    padding: .4rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    font-size: .82rem;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:hover:not(.active) { background: var(--border-light); }

/* ─── Task Checklist ──────────────────────── */
.task-list { list-style: none; }
.task-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border-light);
    font-size: .88rem;
}
.task-item:last-child { border-bottom: none; }
.task-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.task-item.done span { text-decoration: line-through; color: var(--text-light); }
.task-item .task-delete {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: .9rem;
    padding: .2rem;
}
.task-item .task-delete:hover { color: var(--danger); }

/* ─── Calendar ────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cal-header {
    background: var(--border-light);
    padding: .6rem;
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}
.cal-day {
    background: #fff;
    min-height: 90px;
    padding: .4rem;
    font-size: .78rem;
}
.cal-day.today { background: #eff6ff; }
.cal-day.other-month { background: #f8fafc; color: var(--text-light); }
.cal-day-num { font-weight: 600; margin-bottom: .3rem; font-size: .82rem; }
.cal-event {
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .7rem;
    margin-bottom: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* ─── Footer ──────────────────────────────── */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
    font-size: .82rem;
}
footer a { color: var(--text-muted); }

/* ─── Utilities ───────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .82rem; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ─── Post Tab Active ─────────────────────── */
.post-tab.active {
    background: var(--border-light) !important;
    color: var(--primary);
}

/* ─── Task Detail Panel ──────────────────── */
.task-detail-panel {
    list-style: none;
    padding: 0 .8rem .8rem 2.8rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--border-light);
}
.task-detail-inner {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .8rem;
}
.task-detail-section {
    margin-bottom: .6rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--border-light);
}
.task-detail-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.task-detail-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: .4rem;
}
.task-comments-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    max-height: 250px;
    overflow-y: auto;
}
.task-comment-item {
    padding: .45rem .6rem;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    font-size: .82rem;
}
.task-item {
    cursor: pointer;
}
.task-item:hover {
    background: #f8fafc;
}
.task-title-text:hover {
    color: var(--primary);
    text-decoration: underline;
}
.task-ctype-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ─── Notification Bell ──────────────────── */
.notification-bell {
    position: relative;
    cursor: pointer;
    padding: .3rem .6rem;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.notification-bell:hover {
    background: rgba(255,255,255,.1);
}
.bell-icon {
    font-size: 1.15rem;
}
.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.notification-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 300;
    overflow: hidden;
}
.notification-dropdown.show {
    display: block;
}
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--border-light);
}
.notif-header a {
    color: var(--primary);
    text-decoration: none;
}
.notif-header a:hover {
    text-decoration: underline;
}
.notif-list {
    max-height: 350px;
    overflow-y: auto;
}
.notif-item {
    display: flex;
    gap: .6rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text);
    transition: background .1s;
}
.notif-item:hover {
    background: var(--border-light);
    text-decoration: none;
}
.notif-item.unread {
    background: #eff6ff;
}
.notif-item.unread:hover {
    background: #dbeafe;
}
.notif-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    padding-top: .1rem;
}
.notif-content {
    flex: 1;
    min-width: 0;
}
.notif-msg {
    font-size: .82rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-item.unread .notif-msg {
    font-weight: 600;
}
.notif-time {
    font-size: .7rem;
    color: var(--text-light);
    margin-top: .15rem;
}

/* ─── Responsive ──────────────────────────── */
@media (max-width: 768px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; }
    .container { padding: 1rem; }
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns:2fr 1fr"],
    [style*="grid-template-columns:380px 1fr"],
    [style*="grid-template-columns: 380px 1fr"],
    [style*="grid-template-columns:340px 1fr"],
    [style*="grid-template-columns:360px 1fr"],
    [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    .notification-dropdown {
        width: 280px;
        right: -60px;
    }
}

/* ── Audit Log Timeline ───────────────────── */
.audit-timeline {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.audit-entry {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.audit-entry-danger {
    border-left: 4px solid var(--danger);
}
.audit-entry-success {
    border-left: 4px solid var(--success);
}
.audit-entry-header {
    padding: .6rem 1rem .1rem 1rem;
}
.audit-entry-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.audit-entry-date {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
}
.audit-entry-time {
    font-size: .75rem;
    color: var(--text-muted);
}
.audit-entry-ip {
    font-size: .7rem;
    color: var(--text-light);
    font-family: monospace;
    margin-left: auto;
}
.audit-entry-narrative {
    padding: .3rem 1rem .7rem 1rem;
    font-size: .88rem;
    line-height: 1.6;
    color: var(--text);
}
.audit-entry-narrative strong {
    color: var(--text);
}
.audit-id {
    font-size: .7rem;
    color: var(--text-light);
    font-family: monospace;
}
.audit-entry-details {
    border-top: 1px solid var(--border);
    padding: .7rem 1rem;
    background: #f8fafc;
}
/* Sections inside details */
.audit-section {
    margin-bottom: .3rem;
}
.audit-section-title {
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: .4rem;
    padding: .2rem .5rem;
    border-radius: 4px;
    display: inline-block;
}
.audit-section-create {
    color: #166534;
    background: #dcfce7;
}
.audit-section-delete {
    color: #991b1b;
    background: #fee2e2;
}
.audit-section-update {
    color: #1e40af;
    background: #dbeafe;
}
/* Field rows */
.audit-fields {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.audit-field-row {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .4rem .6rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .84rem;
}
.audit-field-changed {
    border-left: 3px solid var(--primary);
}
.audit-field-label {
    font-weight: 700;
    color: var(--text-muted);
    font-size: .78rem;
    min-width: 110px;
    flex-shrink: 0;
    padding-top: .1rem;
}
.audit-field-value {
    flex: 1;
}
.audit-field-diff {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.audit-before, .audit-after {
    display: flex;
    align-items: baseline;
    gap: .4rem;
}
.audit-diff-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-light);
    min-width: 36px;
}
.audit-val-old {
    background: #fee2e2;
    color: #991b1b;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .82rem;
    text-decoration: line-through;
    display: inline;
    word-break: break-word;
}
.audit-val-new {
    background: #dcfce7;
    color: #166534;
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .82rem;
    font-weight: 600;
    display: inline;
    word-break: break-word;
}
.audit-null {
    color: #94a3b8;
    font-style: italic;
    font-size: .82rem;
}
.badge-gray {
    background: #f1f5f9;
    color: #64748b;
}
.badge-purple {
    background: #f3e8ff;
    color: #7c3aed;
}

/* ── Overdue Page ─────────────────────────── */
.overdue-list {
    display: flex;
    flex-direction: column;
}
.overdue-item {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--warning);
}
.overdue-item:last-child { border-bottom: none; }
.overdue-warn { border-left-color: #f59e0b; }
.overdue-high { border-left-color: #ea580c; background: #fffbeb; }
.overdue-critical { border-left-color: #dc2626; background: #fef2f2; }
.overdue-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .5rem;
}
.overdue-item-title {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.overdue-days {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: .3rem .6rem;
    min-width: 70px;
}
.overdue-days-num {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--danger);
    line-height: 1;
}
.overdue-days-label {
    font-size: .62rem;
    color: #991b1b;
    text-align: center;
    line-height: 1.2;
    margin-top: .15rem;
}
.overdue-item-body {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-bottom: .5rem;
}
.overdue-detail {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .84rem;
    flex-wrap: wrap;
}
.overdue-detail-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .78rem;
    min-width: 80px;
}
.overdue-item-actions {
    display: flex;
    gap: .4rem;
}
