@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    --sidebar-width: 268px;
    --sidebar-collapsed-width: 76px;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --body-bg: #f4f6fb;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 48%, #172554 100%);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --radius: 0.875rem;
    --radius-lg: 1.125rem;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--body-bg);
    font-family: var(--font-sans);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Bootstrap overrides */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.btn-primary,
.btn-outline-primary:hover {
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }
.badge.bg-primary-subtle { background: #eef2ff !important; color: var(--primary) !important; }

.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* —— Sidebar —— */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    transition: width var(--transition), transform var(--transition);
    overflow-x: hidden;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-nav-label,
.sidebar.collapsed .nav-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0.5rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.35rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--sidebar-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    color: #fff;
}

.sidebar-collapse-btn {
    margin-left: auto;
    color: #94a3b8 !important;
    opacity: 0.8;
}

.sidebar-collapse-btn:hover {
    color: #fff !important;
    opacity: 1;
}

.sidebar-nav {
    padding: 1rem 0.85rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    padding: 0.5rem 0.85rem 0.35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0.65rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #f8fafc;
    transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    min-width: 1.4rem;
    text-align: center;
}

/* —— Main layout —— */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0;
}

.page-heading {
    line-height: 1.2;
}

.page-heading .page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin: 0;
}

.page-heading .page-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.header-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.85rem;
}

.content-area {
    flex: 1;
    padding: 1.5rem 1.75rem 2rem !important;
}

/* Dashboard hero search */
.dashboard-search {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-md);
}

.dashboard-search-form .input-group {
    border-radius: 1rem;
    overflow: hidden;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.dashboard-search-form .input-group:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.dashboard-search-form .input-group-text {
    background: #f8fafc;
    border: none;
    padding: 0 1.25rem;
    font-size: 1.35rem;
    color: var(--primary);
}

.dashboard-search-form .form-control {
    border: none;
    padding: 1.1rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    background: var(--surface);
}

.dashboard-search-form .form-control:focus {
    box-shadow: none;
}

.dashboard-search-form .form-control::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.dashboard-search-form .btn-primary {
    font-size: 1rem;
    padding: 0 2rem;
    font-weight: 600;
    border-radius: 0;
}

@media (max-width: 575.98px) {
    .dashboard-search {
        padding: 1.15rem;
    }

    .dashboard-search-form .form-control {
        font-size: 1rem;
        padding: 0.85rem 0.35rem;
    }

    .dashboard-search-form .btn-primary {
        padding: 0 1.25rem;
        font-size: 0.9rem;
    }
}

.app-footer {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* —— Cards —— */
.stat-card,
.table-card,
.card-app {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card-clickable {
    cursor: pointer;
}

.stat-card-clickable:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.stat-card-clickable .stat-card-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.stat-card .card-body {
    padding: 1.25rem 1.35rem;
}

.stat-card-primary { border-left: 4px solid var(--primary); }
.stat-card-info    { border-left: 4px solid var(--info); }
.stat-card-warning { border-left: 4px solid var(--warning); }
.stat-card-success { border-left: 4px solid var(--success); }
.stat-card-indigo  { border-left: 4px solid #6366f1; }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.card-header-app {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.35rem;
}

.card-header-app .card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header-app .card-title i {
    color: var(--primary);
}

/* —— Tables —— */
.table-app {
    margin: 0;
    font-size: 0.9rem;
}

.table-app thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    white-space: nowrap;
}

.table-app tbody td {
    padding: 0.95rem 1.25rem;
    vertical-align: middle;
    border-color: #f1f5f9;
}

.table-app tbody tr {
    transition: background var(--transition);
}

.table-app tbody tr:hover {
    background: #f8fafc;
}

.table-empty {
    padding: 3rem 1rem !important;
    color: var(--text-muted);
}

/* —— Badges —— */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
    letter-spacing: 0.02em;
}

/* —— Buttons —— */
.btn {
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    transition: all var(--transition);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
}

/* —— Forms & filters —— */
.form-control,
.form-select {
    border-color: var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* —— Progress —— */
.progress-thin {
    height: 6px;
    border-radius: 999px;
    background: #e2e8f0;
}

.progress-thin .progress-bar {
    border-radius: 999px;
}

/* —— Alerts —— */
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.alert-success { background: #ecfdf5; color: #047857; }
.alert-danger  { background: #fef2f2; color: #b91c1c; }
.alert-info    { background: #eff6ff; color: #1d4ed8; }

/* —— Modals —— */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.15rem 1.35rem;
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.modal-body { padding: 1.35rem; }
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.35rem;
}

/* Task modal: 3-line title; worker column unchanged */
.task-modal .task-title-input {
    font-size: 1.05rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    line-height: 1.5;
    min-height: 5.5rem;
    resize: vertical;
}

.task-modal .task-worker-col {
    padding-top: 0;
}

.task-modal .task-worker-select {
    font-size: 0.9rem;
    padding: 0.375rem 0.75rem;
    height: calc(1.5em + 0.75rem + 2px);
}

/* —— Login —— */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
    top: -120px;
    right: -80px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.2) 0%, transparent 70%);
    bottom: -80px;
    left: -60px;
    pointer-events: none;
}

.login-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.login-card .card-body {
    padding: 2.25rem 2rem;
}

.login-brand {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--sidebar-active);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.login-card .input-group-text {
    background: #f8fafc;
    border-color: var(--border);
    color: var(--text-muted);
}

.login-hint {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1035;
}

@media (max-width: 767.98px) {
    .content-area {
        padding: 1rem !important;
    }
}

@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

.task-status-form {
    min-width: 0;
}

.status-quick-select {
    font-size: 0.8rem;
    border-radius: 8px;
    min-width: 130px;
}

.duration-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    height: 100%;
}

.duration-card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 600;
}

.duration-card-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
}

.duration-card-pending .duration-card-time { color: #64748b; }
.duration-card-in_progress .duration-card-time { color: #2563eb; }
.duration-card-completed .duration-card-time { color: #16a34a; }

.task-view-dl dt {
    font-size: 0.8rem;
    color: #64748b;
}

.status-log-table th {
    font-size: 0.75rem;
    white-space: nowrap;
}

.task-meta-panel {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    max-height: 220px;
    overflow-y: auto;
}

.status-timeline-item {
    position: relative;
    padding-left: 1.25rem;
    padding-bottom: 0.85rem;
}

.status-timeline-item:last-child {
    padding-bottom: 0;
}

.status-timeline-dot {
    position: absolute;
    left: 0;
    top: 0.35rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.status-gap {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.task-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.task-attachment-item {
    width: 100px;
}

.task-attachment-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* —— Mobile-first touch targets —— */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

@media (max-width: 767.98px) {
    .table-app thead { font-size: 0.7rem; }
    .table-app td, .table-app th { padding: 0.5rem 0.35rem; }
    .status-quick-select { min-width: 110px; font-size: 0.75rem; }
    .content-area { padding: 0.75rem !important; }
    .stat-card .stat-value { font-size: 1.35rem; }
    .card-header-app { flex-direction: column; align-items: stretch !important; }
    .modal-dialog { margin: 0.5rem; }
    .task-attachment-item { width: 80px; }
    .task-attachment-item img { width: 80px; height: 80px; }
}

.notification-badge { font-size: 0.65rem; padding: 0.25em 0.45em; }
.notification-unread { background: #eef2ff !important; border-left: 3px solid var(--primary); }
.comment-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }

/* —— Dark mode —— */
[data-bs-theme="dark"] {
    --body-bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    color-scheme: dark;
}

[data-bs-theme="dark"] body {
    background-color: var(--body-bg);
    color: var(--text);
}

[data-bs-theme="dark"] .top-navbar,
[data-bs-theme="dark"] .table-card,
[data-bs-theme="dark"] .filter-bar,
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content {
    background: var(--surface) !important;
    color: var(--text);
    border-color: var(--border);
}

[data-bs-theme="dark"] .table-app {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0f172a;
    border-color: var(--border);
    color: var(--text);
}

[data-bs-theme="dark"] .task-meta-panel,
[data-bs-theme="dark"] .notification-unread {
    background: #0f172a !important;
}

[data-bs-theme="dark"] .header-user-chip {
    background: var(--surface);
    border-color: var(--border);
}
