/* ==========================================================================
   Catalogue Task Tracker — styles
   Palette: graphite ink base, warm brass accent, quiet neutrals.
   Headings: slab serif. UI text: system sans.
   ========================================================================== */

:root {
    --ink:        #23262b;
    --ink-soft:   #565b64;
    --paper:      #fbfaf8;
    --panel:      #ffffff;
    --line:       #e2ded6;
    --brass:      #a9803f;
    --brass-dark: #8a6830;
    --brass-tint: #f4ead9;

    --low:    #6b7280;
    --medium: #a9803f;
    --high:   #c1622b;
    --urgent: #a3312a;

    --radius: 3px;
    --font-head: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: var(--font-head);
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 0.5em;
    color: var(--ink);
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

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

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--ink);
    color: #d8d6d2;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
}
.sidebar .brand {
    font-family: var(--font-head);
    font-size: 1.15rem;
    color: #fff;
    margin-bottom: 28px;
    line-height: 1.3;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar nav a {
    color: #c9c7c2;
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 0.93rem;
}
.sidebar nav a:hover { background: #33363c; text-decoration: none; }
.sidebar nav a.active { background: var(--brass-dark); color: #fff; }
.sidebar .section-label {
    color: #83807a;
    font-size: 0.75rem;
    margin: 18px 0 4px 10px;
}
.sidebar .spacer { flex: 1; }
.sidebar .who {
    border-top: 1px solid #3a3d43;
    padding-top: 14px;
    font-size: 0.85rem;
    color: #a7a49f;
}
.sidebar .who strong { color: #fff; display: block; }
.sidebar .who a { color: #d8b374; font-size: 0.82rem; }

/* --- Main content --- */
.main {
    flex: 1;
    padding: 30px 36px;
    max-width: 980px;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header .actions { display: flex; gap: 8px; }

/* --- Flash messages --- */
.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.92rem;
    border: 1px solid transparent;
}
.flash-success { background: #eaf3e8; border-color: #bfdcb8; color: #2c5c25; }
.flash-error   { background: #fbeaea; border-color: #e6b8b6; color: #8a2c26; }
.flash-info    { background: #eef3f8; border-color: #bcd3e6; color: #2c516f; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.88rem;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
}
.btn:hover { background: #f2f0ec; text-decoration: none; }
.btn-primary { background: var(--brass); border-color: var(--brass-dark); color: #fff; }
.btn-primary:hover { background: var(--brass-dark); }
.btn-danger { border-color: #c9a3a1; color: #8a2c26; }
.btn-danger:hover { background: #fbeaea; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }

/* --- Forms --- */
label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin: 14px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=email], input[type=file],
select, textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    font-family: var(--font-body);
    font-size: 0.94rem;
    color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--brass);
    outline-offset: 1px;
    border-color: var(--brass);
}
.form-row { display: flex; gap: 16px; }
.form-row > div { flex: 1; }
.form-hint { font-size: 0.78rem; color: #8b8880; margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; }
form .form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* --- Card / panel --- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 18px;
}

/* --- Priority chip --- */
.chip {
    display: inline-block;
    font-size: 0.74rem;
    padding: 2px 9px;
    border-radius: 999px;
    color: #fff;
    letter-spacing: 0.02em;
}
.chip-low    { background: var(--low); }
.chip-medium { background: var(--medium); }
.chip-high   { background: var(--high); }
.chip-urgent { background: var(--urgent); }

.badge-disabled {
    display: inline-block;
    font-size: 0.72rem;
    color: #8a2c26;
    background: #fbeaea;
    padding: 1px 8px;
    border-radius: 999px;
}
.badge-completed {
    display: inline-block;
    font-size: 0.72rem;
    color: #2c5c25;
    background: #eaf3e8;
    padding: 1px 8px;
    border-radius: 999px;
}

/* --- Task list --- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 16px;
}
.task-row.is-completed { opacity: 0.62; }
.task-row .row-check { width: auto; flex-shrink: 0; margin: 0; }
.task-row .task-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}
.task-row .task-main:hover .task-message { text-decoration: underline; }
.task-row .task-message {
    color: var(--ink);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    flex-shrink: 1;
}
.task-row .task-meta {
    font-size: 0.78rem;
    color: var(--ink-soft);
    margin-left: auto;
    padding-left: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.filter-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-tabs a {
    padding: 6px 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.85rem;
}
.filter-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* --- Bulk action toolbar --- */
.bulk-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--brass-tint);
    border: 1px solid #e0cfa8;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
#selectionCount { color: var(--ink-soft); }
.bulk-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Task detail --- */
.task-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.task-body { white-space: pre-wrap; margin: 14px 0; }
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 20px;
    font-size: 0.86rem;
    color: var(--ink-soft);
    margin: 16px 0;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.meta-grid strong { display: block; color: var(--ink); font-weight: 600; }

/* --- Attachments --- */
.attachment-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.attachment-list-scroll {
    max-height: 460px;
    overflow-y: auto;
    padding-right: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    background: #fbfaf8;
}
.attachment-row {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 9px 12px;
    background: var(--panel);
}
.attachment-row .attachment-check { width: auto; flex-shrink: 0; margin: 0; }
.attachment-thumb {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7f5f1;
    border: 1px solid var(--line);
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment-icon { font-size: 2.2rem; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name {
    font-size: 0.9rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-meta { font-size: 0.76rem; color: var(--ink-soft); margin-top: 2px; }

/* --- Attachment folder tree --- */
.attachment-folder { display: flex; flex-direction: column; gap: 8px; }
.attachment-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px 7px 8px;
    background: #f2efe9;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.88rem;
}
.attachment-folder-header .folder-check { width: auto; flex-shrink: 0; margin: 0; }
.folder-toggle {
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    width: 14px;
    flex-shrink: 0;
}
.attachment-folder-icon { flex-shrink: 0; }
.attachment-folder-name { color: var(--ink); font-weight: 600; }
.attachment-folder-count { color: var(--ink-soft); font-size: 0.78rem; margin-left: auto; }
.attachment-folder-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.attachment-folder.collapsed > .attachment-folder-body { display: none; }
.attachment-folder.collapsed > .attachment-folder-header .folder-toggle { transform: rotate(-90deg); }

.dropzone {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    background: #f7f5f1;
    cursor: pointer;
    position: relative;
}
.dropzone.dragover { border-color: var(--brass); background: var(--brass-tint); }
#dropzoneText { color: var(--ink-soft); font-size: 0.88rem; pointer-events: none; }
.dropzone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.dropzone-folder-row { margin-top: 8px; }

.upload-progress {
    display: none;
    margin-top: 10px;
}
.upload-progress.active { display: block; }
.upload-progress-row { display: flex; align-items: center; gap: 10px; }
.upload-progress-track {
    flex: 1;
    height: 8px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--brass);
    transition: width 0.15s ease;
}
.upload-progress-text { font-size: 0.78rem; color: var(--ink-soft); min-width: 34px; text-align: right; }
.upload-progress-files { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }
#uploadCancelBtn { display: none; flex-shrink: 0; }

/* --- Comments --- */
.comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.comment:last-child { border-bottom: none; }
.comment-meta { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 3px; }
.comment-meta strong { color: var(--ink); }
.comment-body { white-space: pre-wrap; font-size: 0.93rem; }

/* --- Tables (admin users) --- */
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th, table.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
}
table.data-table th { color: var(--ink-soft); font-weight: 600; font-size: 0.78rem; }
table.data-table tr:hover td { background: #f7f5f1; }

/* --- Login --- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
}
.login-box {
    background: var(--paper);
    padding: 36px 34px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 340px;
}
.login-box h1 { text-align: center; margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 22px; }

/* --- Responsive --- */
@media (max-width: 760px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar .brand { margin-bottom: 0; margin-right: auto; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar .spacer { display: none; }
    .sidebar .who { border-top: none; padding-top: 0; }
    .main { padding: 20px; }
    .form-row { flex-direction: column; gap: 0; }
}

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
