/*
 * Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com). All Rights Reserved.
 *
 * This software is the property of WSO2 Inc. and its suppliers, if any.
 * Dissemination of any information or reproduction of any material contained
 * herein in any form is strictly forbidden, unless permitted by WSO2 expressly.
 * You may not alter or remove any copyright or other notice from copies of this content.
 */

:root {
    --brand: #ff7300;
    --brand-dark: #e56700;
    --brand-soft: #fff1e6;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e6e8ec;
    --text: #1d2330;
    --muted: #6b7280;
    --sidebar: #11151c;
    --sidebar-text: #aeb4bf;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warning: #b45309;
    --warning-soft: #fef3e2;
    --success: #15803d;
    --success-soft: #e8f6ed;
    --neutral-soft: #eef0f3;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--brand-dark);
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ---------- App shell ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    padding: 20px 14px;
    z-index: 20;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 22px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
}

.sidebar .brand img {
    height: 28px;
}

.sidebar .brand span {
    padding-left: 10px;
    border-left: 1px solid #2b313b;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar .nav-label {
    margin: 18px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #5f6672;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
}

.sidebar nav a:hover {
    background: #1b212b;
    color: #fff;
}

.sidebar nav a.active {
    background: rgba(255, 115, 0, 0.14);
    color: #fff;
}

.sidebar nav a.active .icon {
    color: var(--brand);
}

.sidebar nav a .count {
    margin-left: auto;
    min-width: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.main {
    margin-left: 240px;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    height: 60px;
    padding: 0 32px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 9px;
    background: var(--neutral-soft);
}

.segmented a {
    padding: 5px 12px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.segmented a.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
}

.user-chip .who {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-chip .who strong {
    font-weight: 600;
}

.user-chip .who small {
    color: var(--muted);
    font-size: 12px;
}

.user-chip .logout {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-left: 4px;
    border-radius: 8px;
    color: var(--muted);
}

.user-chip .logout:hover {
    background: var(--neutral-soft);
    color: var(--text);
}

.content {
    padding: 28px 32px 48px;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.page-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

/* ---------- Buttons & form controls ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--neutral-soft);
}

.btn-block {
    width: 100%;
}

.search {
    position: relative;
}

.search .icon {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--muted);
}

.search input[type="text"] {
    width: 320px;
    padding-left: 38px;
}

input[type="text"],
input[type="date"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(255, 115, 0, 0.15);
}

input[readonly] {
    background: var(--neutral-soft);
    color: var(--muted);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.field .hint {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 6px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 24px;
}

.card h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 600;
}

.form-card {
    max-width: 640px;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 500;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

/* ---------- Stats ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    color: inherit;
    text-decoration: none;
}

.stat .stat-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

.stat .stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
}

.stat .stat-label {
    color: var(--muted);
    font-size: 13px;
}

.tone-brand { background: var(--brand-soft); color: var(--brand-dark); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-neutral { background: var(--neutral-soft); color: var(--muted); }

/* ---------- Task cards ---------- */

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

/* Each card's five sections (head, description, details, remark, footer) sit on shared
   grid rows, so they line up across the cards in a row. */
.task-card {
    display: grid;
    grid-row: span 5;
    grid-template-rows: subgrid;
    row-gap: 0;
    margin-bottom: 16px;
    padding: 20px;
    border-top: 3px solid transparent;
}

.task-card.status-overdue { border-top-color: var(--danger); }
.task-card.status-due { border-top-color: #f59e0b; }
.task-card.status-ok { border-top-color: #22c55e; }
.task-card.status-none { border-top-color: #cbd0d8; }

.task-card .task-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.task-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.task-card .desc {
    margin: 0 0 16px;
    min-height: 4.5em;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin: 0 0 16px;
}

.meta dt {
    color: var(--muted);
    font-size: 12px;
}

.meta dd {
    margin: 2px 0 0;
    font-weight: 500;
    word-break: break-word;
}

.meta .wide {
    grid-column: 1 / -1;
}

.task-card .remark {
    margin-bottom: 16px;
}

.task-card .remark .label {
    color: var(--muted);
    font-size: 12px;
}

.task-card .remark .text {
    margin: 2px 0 0;
    font-weight: 500;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-card .task-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    align-self: end;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.task-card .task-foot .when {
    color: var(--muted);
    font-size: 13px;
}

.task-card .task-foot .when strong {
    color: var(--text);
}

/* ---------- Empty state & pagination ---------- */

.empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--muted);
}

.empty .icon {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
    color: #c2c7cf;
}

.empty h3 {
    margin: 0 0 4px;
    color: var(--text);
    font-size: 16px;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.pagination a {
    min-width: 36px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    text-align: center;
    text-decoration: none;
    font-weight: 500;
}

.pagination a.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 220px);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    background: #fafbfc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr:hover {
    background: #fafbfc;
}

td.nowrap {
    white-space: nowrap;
}

td .clamp {
    max-width: 320px;
    color: var(--muted);
}

/* ---------- Report cards ---------- */

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

.report-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-card p {
    margin: 0;
    color: var(--muted);
}

.report-card form {
    margin-top: auto;
}

/* ---------- Review pop-up (also used by the standalone review page) ---------- */

.modal {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: none;
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 48px rgba(16, 24, 40, 0.22);
}

.modal::backdrop {
    background: rgba(17, 21, 28, 0.45);
    backdrop-filter: blur(2px);
}

.modal[open] {
    animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-loading {
    padding: 48px;
    text-align: center;
    color: var(--muted);
}

.review-page {
    max-width: 640px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-head > div {
    flex: 1;
    min-width: 0;
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
}

.modal-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.modal-close {
    width: 32px;
    height: 32px;
    margin: -4px -8px 0 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--neutral-soft);
    color: var(--text);
}

.modal-body {
    padding: 18px 24px 6px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
    border-radius: 0 0 14px 14px;
}

.review-desc {
    margin: 0 0 14px;
    color: var(--muted);
}

.review-meta {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--neutral-soft);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.history {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.history summary {
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
}

.history ul {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--border);
}

.history li {
    display: grid;
    grid-template-columns: 96px 150px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.history li:last-child {
    border-bottom: none;
}

.history .when {
    white-space: nowrap;
}

.history .who,
.history .what {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

/* ---------- Login ---------- */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: radial-gradient(circle at 20% 0%, #fff1e6 0, transparent 45%), var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 36px;
    text-align: center;
}

.login-card img {
    height: 44px;
    margin-bottom: 24px;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-card p {
    margin: 0 0 28px;
    color: var(--muted);
}

.login-card .alert {
    text-align: left;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: auto; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 40px; }
    .search input { width: 100%; }
    .user-chip .who small { display: none; }
    .field-row { grid-template-columns: 1fr; }
    .history li { grid-template-columns: 1fr; gap: 2px; }
}
