@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
    --bg: #f3f6f4;
    --ink: #16302b;
    --muted: #5f746e;
    --brand: #0f6e56;
    --brand-dark: #0b4f3e;
    --accent: #d97706;
    --panel: #ffffff;
    --line: #d7e3de;
    --sidebar: #102a24;
    --shadow: 0 10px 30px rgba(16, 42, 36, 0.08);
    --radius: 16px;
    --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
    --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 110, 86, 0.12), transparent 28%),
        linear-gradient(180deg, #eef5f1 0%, var(--bg) 45%, #e8f0ec 100%);
    min-height: 100vh;
}

h1, h2, .brand strong, .guest-brand h1 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.app-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #14362e 0%, var(--sidebar) 100%);
    color: #e7f2ee;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1fa37c, #0f6e56);
    font-weight: 700;
    color: #fff;
}

.brand small, .user-chip small {
    display: block;
    color: #9db5ad;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.side-nav .nav-link {
    color: #d7e8e2;
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.side-nav .nav-link:hover,
.side-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-footer {
    display: grid;
    gap: 0.75rem;
}

.user-chip {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 0.75rem;
}

.main {
    min-width: 0;
    min-height: 100vh;
}

.content { padding: 1.5rem; }

/* Página de detalhe do projeto: painéis em altura total da tela */
.main:has(.project-show-page) {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.main:has(.project-show-page) .content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.project-show-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.project-show-page .page-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.project-show-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.project-main-panel,
.project-comments-panel {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.project-main-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 0.15rem;
}

.project-comments-title {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

.project-comments-panel .project-comments-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin-bottom: 0;
    padding-right: 0.15rem;
}

.project-comments-panel .entity-comments {
    max-height: none;
    overflow: visible;
}

.project-comment-form {
    flex-shrink: 0;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.8rem;
    margin: 0 0 0.25rem;
}

.panel, .stat-tile, .filter-bar, .guest-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel { padding: 1.25rem; }

.stat-tile {
    padding: 1.1rem 1.2rem;
    display: grid;
    gap: 0.35rem;
}

.stat-tile span {
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-tile strong {
    font-size: 1.8rem;
    font-family: var(--font-display);
}

.stat-tile.danger strong { color: #b42318; }
.stat-tile.success strong { color: var(--brand); }

.filter-bar { padding: 1rem; }

.comments-list {
    max-height: 360px;
    overflow: auto;
}

.comment-item {
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 0;
}

.comment-item:last-child { border-bottom: 0; }
.comment-item small { display: block; color: var(--muted); margin-bottom: 0.25rem; }
.comment-item p { margin: 0; }

.timeline li {
    padding: 0.65rem 0;
    border-bottom: 1px dashed var(--line);
}

.timeline li:last-child { border-bottom: 0; }

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        linear-gradient(135deg, rgba(15, 110, 86, 0.88), rgba(16, 42, 36, 0.92)),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.guest-wrap { width: min(460px, 100%); }
.guest-card { padding: 1.75rem; }

.guest-brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.guest-brand h1 {
    font-size: 1.45rem;
    margin: 0;
}

.guest-brand p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(16, 42, 36, 0.45);
    display: grid;
    place-items: center;
    z-index: 2000;
}

#confirmModal .modal-title,
#taskFormModal .modal-title {
    font-family: var(--font-display);
}

#taskFormModal .modal-header {
    border-bottom-color: var(--line);
    background: linear-gradient(180deg, #f7fbf9, #fff);
}

#taskDetailModal .modal-content {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

#taskDetailModal .modal-header {
    border-bottom-color: var(--line);
    background: linear-gradient(180deg, #f7fbf9, #fff);
    padding: 1rem 1.25rem;
}

#taskDetailModal .modal-title {
    font-family: var(--font-display);
}

#taskDetailModal .modal-body {
    padding: 1.1rem 1.25rem 1.25rem;
}

.task-modal-body {
    display: grid;
    gap: 1rem;
}

.task-modal-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f7fbf9;
}

.task-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 0.75rem 1.5rem;
    align-items: start;
    flex: 1;
    min-width: 0;
}

.task-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.task-meta-label {
    display: block;
    font-size: 0.72rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

.task-meta-value {
    display: flex;
    align-items: center;
    min-height: 1.75rem;
}

.task-meta-value a,
.task-meta-value strong {
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--ink);
}

.task-meta-project .task-meta-value a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-meta-value .badge {
    width: fit-content;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4em 0.7em;
    line-height: 1.1;
    font-weight: 600;
    white-space: nowrap;
}

.task-meta-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    margin-left: auto;
}

.task-meta-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.task-section {
    min-width: 0;
}

.task-section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
    margin: 0 0 0.55rem;
}

.task-description {
    margin: 0;
    line-height: 1.55;
    color: var(--ink);
}

.task-status-bar {
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.task-status-bar .status-form {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.task-status-bar .form-select {
    width: auto;
    min-width: 180px;
}

.task-modal-split {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
    gap: 1rem;
    align-items: start;
}

.task-comments-panel,
.task-aside .task-section {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem;
    background: #fff;
}

.task-aside {
    display: grid;
    gap: 1rem;
}

.comments-wrap,
.task-comments-wrap,
.project-comments-wrap {
    margin-bottom: 0.75rem;
}

.entity-comments,
.task-comments {
    max-height: 280px;
    overflow: auto;
    padding-right: 0.25rem;
}

.comments-pagination,
.task-comments-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
}

.entity-comments .comment-item,
.task-comments .comment-item {
    padding: 0.55rem 0;
}

.entity-comments .comment-head,
.task-comments .comment-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    margin-bottom: 0.2rem;
}

.entity-comments .comment-head small,
.task-comments .comment-head small {
    color: var(--muted);
    white-space: nowrap;
}

.task-comments-panel .comment-form {
    display: grid;
    gap: 0.55rem;
}

.task-people li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0;
}

.task-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(15, 110, 86, 0.12);
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.task-history li {
    padding: 0.5rem 0;
}

.task-history .history-line {
    display: grid;
    gap: 0.15rem;
    font-size: 0.92rem;
}

.task-modal-link {
    cursor: pointer;
}

@media (max-width: 991px) {
    .task-modal-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .task-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 1rem;
    }

    .task-meta-actions {
        margin-left: 0;
        justify-content: flex-end;
    }

    .task-modal-split {
        grid-template-columns: 1fr;
    }
}

.topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
}

@media (max-width: 991px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, 86vw);
        transform: translateX(-105%);
        transition: transform .25s ease;
        z-index: 1050;
    }
    .sidebar.open { transform: translateX(0); }

    .main:has(.project-show-page) {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .main:has(.project-show-page) .content {
        overflow: visible;
    }

    .project-show-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .project-main-panel,
    .project-comments-panel {
        height: auto;
        max-height: none;
        min-height: 55vh;
    }

    .project-main-scroll,
    .project-comments-panel .project-comments-wrap {
        max-height: 55vh;
    }
}
