/* Base layout */
:root {
  --header-color: transparent;
  --body-text-color: #444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
}

header {
    background: var(--header-color);
    color: white;
    padding: 1rem 2rem;
}

header nav {
    display: flex;
    gap: 2rem;
}

header nav a {
    color: var(--body-text-color);
    text-decoration: none;
}

header nav a:hover {
    text-decoration: underline;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

footer {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 0.9rem;
}

/* Task group template styles */
.task-group-template {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tokens-section, .tasks-section, .actions {
    margin: 2rem 0;
}

.tokens-section h2, .tasks-section h2 {
    font-size: 1.5em;
    margin-bottom: 1rem;
    color: #333;
}

.help-text {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 1rem;
}

.token-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.token-list li {
    background: #f0f0f0;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.token-list code {
    font-family: monospace;
    background: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 2px;
}

.tasks-structure {
    border-left: 3px solid #007bff;
    padding-left: 1.5rem;
}

.task-item {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 4px;
}

.task-item h3 {
    margin: 0 0 0.5rem 0;
    color: #007bff;
}

.labels {
    font-size: 0.9em;
    color: #666;
    margin: 0.5rem 0;
}

.subtasks {
    margin: 1rem 0 0 1.5rem;
    list-style: disc;
}

.subtasks li {
    margin: 0.5rem 0;
}

.subtasks .labels {
    font-size: 0.85em;
    color: #999;
}

.actions {
    text-align: center;
    padding: 2rem 0;
}

.button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
}

.button:hover {
    background: #0056b3;
}

/* Messages */
.messages {
    margin: 1rem 0;
}

.message {
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 4px;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Form styles */
form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

form > div {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
}

.error {
    color: #721c24;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Description preview */
.description-preview {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.description-section {
    margin-bottom: 1rem;
}

.description-text {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: white;
    border-left: 3px solid #007bff;
}

/* Task preview */
.task-preview {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    margin: 2rem 0;
}

.task-list {
    list-style: none;
    padding: 0;
}

.task-list .task-item {
    margin: 1rem 0;
}

.task-labels {
    color: #666;
    font-size: 0.9rem;
}

.subtask-list {
    list-style: none;
    padding-left: 2rem;
    margin-top: 0.5rem;
}

.subtask-item {
    margin: 0.5rem 0;
}

/* Template list (homepage) */
.template-list {
    list-style: none;
    padding: 0;
}

.template-list li {
    background: white;
    margin-bottom: 1rem;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.template-list li a {
    font-size: 1.2em;
    font-weight: 600;
    color: #007bff;
    text-decoration: none;
}

.template-list li a:hover {
    text-decoration: underline;
}

.template-list .template-description {
    color: #666;
    margin-top: 0.5rem;
}

/* Dashboard */
.dashboard h1 {
    margin-bottom: 1.5rem;
    color: #333;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.progress-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #28a745;
    border-radius: 3px;
    transition: width 0.3s;
}

.dashboard-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.dashboard-section h2 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: #333;
}

.create-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.create-links .button {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

details {
    margin-bottom: 1.2rem
}

details > summary {
    cursor: pointer;
}

details > summary > h2 {
    display: inline;
    margin: 0;
}

/* Task group list (tasks from a template) */
.task-group-list {
    list-style: none;
    padding: 0;
}

.task-group-item {
    background: white;
    margin-bottom: 1rem;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.task-group-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.task-meta {
    color: #888;
    font-size: 0.85rem;
}

.task-group-item .subtask-list {
    margin-top: 0.75rem;
}

.task-group-item .subtask-item.completed {
    color: #888;
}

th {
    text-align: left;
}

[hx-get], [hx-post] {
    cursor: pointer;
}

/* Reusable data table — use .task-table on any <table> */
.task-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.875rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
}

.task-table th,
.task-table td {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.task-table th {
    background: #f8f8f8;
    color: #888;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.task-table tbody tr:last-child td {
    border-bottom: none;
}

.task-table tbody tr:hover td {
    background: #fafafa;
}

/* Tag pill — use for action/label values within table cells */
.tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #e8f0fe;
    color: #3d5aad;
}

.tag--sow    { background: #e6f4ea; color: #2d6a4f; }
.tag--plant  { background: #fff3cd; color: #856404; }
.tag--harvest { background: #fde8d8; color: #8c3a1a; }

/* Summary view */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.summary-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.summary-template-label {
    margin: auto 0 0;
    padding-top: 0.6rem;
    font-size: 0.75rem;
    color: #aaa;
    border-top: 1px solid #f0f0f0;
}

.summary-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.summary-card-hidden {
    opacity: 0.6;
    border-left: 3px solid #ccc;
}

.summary-tasklist {
    margin: 0 0 0.75rem;
    padding-left: 1.25rem;
    font-size: 0.9rem;
}

.summary-task-done {
    color: #aaa;
}

.summary-tags {
    font-size: 0.75em;
    color: #999;
    margin-left: 0.4em;
}

.summary-meta {
    font-size: 0.8rem;
    color: #888;
    margin: 0.25rem 0 0.75rem;
}

.bed-section .summary-tasklist {
    padding-left: 0;
}

.bed-section .summary-tasklist li {
    list-style: none;
    padding: 0.35rem 0;
}

.bed-subheading {
    font-size: 1rem;
    font-weight: 600;
    color: #555;
    margin: 1.25rem 0 0.4rem;
}

.bed-subheading:first-of-type {
    margin-top: 0.25rem;
}

.bed-label-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
}

dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    margin: 2vw;
    width: 96vw;
    max-width: 96vw;
    height: 96vh;
    max-height: 96  vh;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

@media (min-width: 640px) {
    dialog {
        width: 500px;
        max-width: 500px;
        margin: auto;
    }
}

.dialog-inner {
    position: relative;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 2rem 1.75rem 1.75rem;
}

.dialog-inner h3 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}

.dialog-inner h4 {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    font-weight: normal;
}

.dialog-inner p a {
    color: inherit;
    text-decoration: none;
    font-weight: bold;
}

.dialog-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #999;
    padding: 0.25rem 0.5rem;
}

.dialog-close:hover {
    color: #333;
}

.dialog-links {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dialog-links li {
    display: flex;
    align-items: center;
}

.dialog-links .priority-group {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

.shorthand-link,
.priority-link {
    display: inline-block;
    padding: 0.45em 1em;
    font-size: 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.4;
}

.shorthand-link {
    border: 1px solid #ccc;
    color: #444;
}

.shorthand-link:hover {
    background: #f0f0f0;
    color: #111;
    border-color: #999;
}

.priority-link {
    color: white;
    opacity: 0.85;
}

.priority-link:hover {
    opacity: 1;
}

.priority-p1 { background: #c0392b; }
.priority-p2 { background: #d46b08; }
.priority-p3 { background: #1a6bb5; }

.summary-empty {
    font-size: 0.85rem;
    color: #aaa;
    font-style: italic;
}

.summary-inactive {
    color: #aaa;
}

.summary-rules {
    margin: 1rem 0;
}

.summary-rules h3 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
}

.summary-rules h4 {
    margin: 1rem 0 0.25rem;
    font-size: 0.9rem;
}

.summary-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.summary-table th,
.summary-table td {
    text-align: left;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.summary-table th {
    color: #888;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-rule-inactive td {
    color: #bbb;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    padding: 0.3rem 0.85rem;
    border: 1px solid #007bff;
    border-radius: 4px;
    background: white;
    color: #007bff;
    font-size: 0.875rem;
    cursor: pointer;
}

.filter-btn.active {
    background: #007bff;
    color: white;
}

.filter-btn:hover:not(.active) {
    background: #e8f0fe;
}

/* Create task group: two-column layout */
.create-task-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .create-task-layout {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .create-task-layout .task-preview {
        position: sticky;
        top: 1rem;
    }
}

/* Beds search */
.beds-search-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: white;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.beds-search-btn:hover {
    color: #333;
    box-shadow: 0 2px 12px rgba(0,0,0,0.22);
}

dialog.search-dialog {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border: none;
    padding: 0;
    width: min(520px, 88vw);
    max-width: min(520px, 88vw);
    height: auto;
    max-height: 80vh;
    margin: 15vh auto 0;
    overflow: visible;
}

@media (min-width: 640px) {
    dialog.search-dialog {
        width: min(520px, 88vw);
        max-width: min(520px, 88vw);
        margin: 15vh auto 0;
    }
}

dialog.search-dialog input[type="search"] {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.875rem 1.25rem;
    font-size: 1.25rem;
    border: none;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    outline: none;
}

dialog.search-dialog .search-suggestions {
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    overflow: hidden;
    margin: 2px 0 0;
}

dialog.search-dialog .search-suggestions button {
    background: white;
    border-radius: 0;
}

dialog.search-dialog .search-suggestions button:hover {
    background: #f5f5f5;
}

@keyframes pending-pulse {
    0%, 100% { background: #e8f4e8; }
    50%       { background: #b8dfb8; }
}

dialog.search-dialog .search-suggestions button.pending {
    animation: pending-pulse 0.6s ease-in-out 1 forwards;
    color: #2a6a2a;
}

.search-suggestions {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.search-suggestions button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    background: #f0f0f0;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
}

.search-suggestions button:hover {
    background: #e0e0e0;
}

@keyframes highlight-fade {
    0%   { background: #fffb8f; }
    100% { background: transparent; }
}

.search-highlight {
    animation: highlight-fade 2s ease-out forwards;
    border-radius: 4px;
}
