/* =========================================
   1. THEME VARIABLES
========================================= */

:root {
    color-scheme: dark;

    --bg: #0d1017;
    --surface: #171b25;
    --input: #10141d;
    --border: #2b3040;

    --text: #f1f5f9;
    --muted: #a0aec0;

    --accent: #a78bfa;
    --primary: #7c3aed;

    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --info: #60a5fa;

    --radius: 8px;
}


/* =========================================
   2. GLOBAL STYLES
========================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;

    background:
        radial-gradient(ellipse at top right,
            #211936 0,
            transparent 40%),
        var(--bg);

    color: var(--text);

    font: 14px/1.5 system-ui, -apple-system, sans-serif;
}

h1,
h2,
h3,
h4,
h5,
p,
form {
    margin: 0;
}

h2 {
    font-size: clamp(24px, 4vw, 32px);
    letter-spacing: -0.035em;
    margin-bottom: 18px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.6;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}


/* =========================================
   3. NAVIGATION AND CONTAINER
========================================= */

nav {
    position: sticky;
    top: 0;
    z-index: 10;

    display: flex;
    align-items: center;
    gap: 20px;

    padding: 12px max(16px, calc((100% - 1120px) / 2));

    background: #10141ded;
    backdrop-filter: blur(14px);

    border-bottom: 1px solid var(--border);
}

nav a {
    display: inline-flex;
    align-items: center;

    font-size: 19px;
    font-weight: 750;

    color: var(--text);
    white-space: nowrap;
}

nav a:first-child::before {
    content: '✓';

    display: inline-grid;
    place-items: center;

    width: 34px;
    height: 34px;

    margin-right: 10px;

    background: var(--primary);
    color: white;

    border-radius: 8px;
}

nav a:hover {
    text-decoration: none;
}

.container {
    width: calc(100% - 32px);
    max-width: 1120px;

    margin: 30px auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;
    margin-bottom: 18px;
}

.page-header h2 {
    margin: 0;
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    font-size: 13px;
}


/* =========================================
   4. COMMON INPUTS AND BUTTONS
========================================= */

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    display: block;

    width: 100%;
    min-width: 0;

    padding: 8px 10px;

    background: var(--input);
    color: var(--text);

    border: 1px solid var(--border);
    border-radius: 6px;

    outline: none;
    color-scheme: dark;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

select {
    cursor: pointer;
}

select option {
    background: var(--input);
    color: var(--text);
}

.primary-button,
.page-header a {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 9px 15px;

    background: var(--primary);
    color: white;

    border: 1px solid transparent;
    border-radius: 6px;

    font-weight: 600;
    white-space: nowrap;

    transition: background 0.15s;
}

.primary-button:hover,
.page-header a:hover {
    background: #6d28d9;
    text-decoration: none;
}


/* =========================================
   5. COMMON TASK STYLES
========================================= */

.task {
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.task:hover {
    border-color: #514369;
}

.task .field,
.task-text,
.description-row {
    min-width: 0;
}

.task-text {
    display: flex;
    flex-direction: column;
}

.task-title {
    font-weight: 600;
}

.description-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.description-row a {
    flex-shrink: 0;

    color: var(--accent);
    font-size: 14px;

    text-decoration: none;
}


/* =========================================
   6. STATUS BUTTON
========================================= */

.status-button {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-button button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;

    padding: 0;

    background: transparent;
    color: var(--muted);

    border: 1px solid transparent;
    border-radius: 5px;

    font-size: 25px;
    line-height: 1;
}

.status-button button:hover {
    background: #282337;
    border-color: var(--border);
}

.task[data-status="IN_PROGRESS"] .status-button button {
    color: var(--info);
}

.task[data-status="COMPLETED"] .status-button button {
    color: var(--success);
}

.task[data-status="COMPLETED"] .task-title {
    color: var(--muted);
    text-decoration: line-through;
}


/* =========================================
   7. PRIORITY COLORS
========================================= */

.priority select:has(option[value="HIGH"]:checked) {
    color: var(--danger);
}

.priority select:has(option[value="MEDIUM"]:checked) {
    color: var(--warning);
}

.priority select:has(option[value="LOW"]:checked) {
    color: var(--success);
}


/* =========================================
   8. TASK LIST LAYOUT
========================================= */

.task-list {
    display: flex;
    flex-direction: column;

    gap: 7px;

    overflow-x: auto;
    padding-bottom: 3px;
}

.task-list .task {
    display: grid;

    grid-template-columns:
        28px minmax(110px, 1fr) 100px 200px 30px;

    align-items: center;

    gap: 8px;

    width: 100%;
    min-width: 520px;

    padding: 7px 10px;
}

.task-list .task>* {
    min-width: 0;
}

.task-list .field>label,
.task-list .status-label {
    display: none;
}

.task-list .status-button {
    justify-content: center;
}

.task-list .task-text {
    gap: 0;
}


/* =========================================
   9. COMPACT TITLE
========================================= */

.task-list .task-title {
    display: block;

    width: 100%;
    height: 25px;

    padding: 2px 5px;

    background: transparent;
    border: 1px solid transparent;

    font-size: 14px;
    line-height: 19px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-list .task-title:hover {
    background: #1d2330;
}

.task-list .task-title:focus {
    background: var(--input);
    border-color: var(--accent);
    text-overflow: clip;
}


/* =========================================
   10. COMPACT DESCRIPTION
========================================= */

.task-list .description-row textarea {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 23px;
    min-height: 23px;
    max-height: 23px;
    padding: 2px 5px;

    background: transparent;
    border: 1px solid transparent;

    color: var(--muted);

    font-size: 12px;
    line-height: 17px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    resize: none;
}

.task-list .description-row textarea:hover {
    background: #1d2330;
}

.task-list .description-row textarea:focus {
    height: 80px;
    min-height: 80px;
    max-height: 200px;

    background: var(--input);
    border-color: var(--accent);

    color: var(--text);

    white-space: pre-wrap;
    overflow: auto;

    resize: vertical;
}


/* =========================================
   11. COMPACT PRIORITY AND DATE
========================================= */

.task-list .priority select,
.task-list .due-date input {
    width: 100%;
    height: 32px;

    padding: 4px 6px;

    font-size: 12px;
    border-radius: 5px;
}


/* =========================================
   12. DELETE BUTTONS
========================================= */

.delete-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 7px 12px;

    background: #ef444410;
    color: var(--danger);

    border: 1px solid #ef444440;
    border-radius: 6px;

    font-size: 13px;
}

.delete-button:hover {
    background: #ef444425;
    border-color: var(--danger);
}

.task-list .delete-form {
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-list .delete-button {
    width: 30px;
    height: 30px;

    padding: 0;

    background: transparent;
    border-color: transparent;
}

.task-list .delete-button:hover {
    background: #ef444420;
    border-color: #ef444440;
}


/* =========================================
   13. QUICK ADD FORM
========================================= */

.quick-add-form {
    display: flex;
    align-items: center;

    gap: 8px;

    width: 100%;

    margin-top: 10px;
    padding: 8px 10px;

    background: var(--surface);

    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.quick-add-form input,
.quick-add-form select {
    height: 34px;

    padding: 5px 9px;
    font-size: 13px;
}

.quick-add-form input {
    flex: 1;
    width: 0;
    min-width: 0;
}

.quick-add-form select {
    flex: 0 0 100px;
    width: 100px;
}

.quick-add-form .primary-button {
    flex: 0 0 34px;

    width: 34px;
    height: 34px;

    padding: 0;

    font-size: 22px;
}


/* =========================================
   14. TASK DETAIL PAGE
========================================= */

.task.task-detail {
    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 15px;

    width: 100%;
    max-width: 760px;

    margin: 18px auto;
    padding: 20px;
}

.task-detail .field {
    display: flex;
    flex-direction: column;

    gap: 5px;
}

.task-detail .field>label {
    display: block;

    color: var(--muted);

    font-size: 13px;
    font-weight: 600;
}

.task-detail .task-text {
    order: 1;
    gap: 15px;
}

.task-detail .status-field {
    order: 2;
}

.task-detail .due-date {
    order: 3;
}

.task-detail .priority {
    order: 4;
}

.task-detail .timestamps {
    order: 5;
}

.task-detail .delete-form {
    order: 6;

    display: flex;
    justify-content: flex-end;
}

.task-detail .status-label {
    display: inline;
}

.task-detail .description-row {
    display: block;
    width: 100%;
}

.task-detail input,
.task-detail select {
    height: 38px;
}


/* =========================================
   15. DETAIL DESCRIPTION EXPANSION
========================================= */

.task-detail .description-row textarea {
    display: block;

    width: 100%;

    height: 38px;
    min-height: 38px;
    max-height: 38px;

    padding: 8px 10px;

    line-height: 20px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    resize: none;
}

.task-detail .description-row textarea:focus {
    height: 90px;
    min-height: 90px;
    max-height: 240px;

    white-space: pre-wrap;
    overflow: auto;

    resize: vertical;
}


/* =========================================
   16. TIMESTAMPS
========================================= */

.timestamps {
    padding: 10px 12px;

    background: var(--input);
    border: 1px solid var(--border);
    border-radius: 6px;

    color: var(--muted);
    font-size: 12px;
}

.timestamps p+p {
    margin-top: 3px;
}


/* =========================================
   17. EMPTY TASK LIST
========================================= */

.null-task {
    padding: 28px 16px;

    text-align: center;
    color: var(--muted);

    border: 1px dashed var(--border);
    border-radius: var(--radius);
}


/* =========================================
   18. DEDICATED CREATE FORM
========================================= */

.create-section {
    width: 100%;
    max-width: 680px;

    margin: 18px auto;
    padding: 20px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.create-section h2 {
    margin-bottom: 18px;
}

.task-create-form {
    display: grid;

    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 14px;
}

.task-create-form .form-group {
    display: flex;
    flex-direction: column;

    gap: 5px;
    min-width: 0;
}

.task-create-form .form-group:has([name="title"]),
.task-create-form .form-group:has([name="description"]) {
    grid-column: 1 / -1;
}

.task-create-form label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.task-create-form input,
.task-create-form select {
    height: 38px;
}

.task-create-form textarea {
    height: 38px;
    min-height: 38px;

    line-height: 20px;

    overflow: hidden;
    resize: none;
}

.task-create-form textarea:focus {
    height: 90px;
    min-height: 90px;

    overflow: auto;
    resize: vertical;
}

.task-create-form .primary-button,
.task-create-form>.errorlist {
    grid-column: 1 / -1;
}


/* =========================================
   19. VALIDATION ERRORS
========================================= */

.errorlist {
    margin: 4px 0;
    padding-left: 18px;

    color: var(--danger);
    font-size: 12px;
}

.helptext {
    color: var(--muted);
    font-size: 12px;
}


/* =========================================
   20. RESPONSIVE LAYOUT
========================================= */

@media (max-width: 750px) {

    .container {
        width: calc(100% - 24px);
        margin: 22px auto;
    }

    .task-list .task {
        grid-template-columns:
            26px minmax(100px, 1fr) 90px 190px 28px;

        min-width: 480px;

        gap: 6px;
        padding: 6px 8px;
    }

    .task-detail,
    .create-section {
        padding: 16px;
    }

}

@media (max-width: 480px) {

    .page-header a {
        padding: 7px 10px;
        font-size: 12px;
    }

    .task-create-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .task.task-detail {
        padding: 14px;
    }

    .quick-add-form {
        gap: 5px;
        padding: 7px;
    }

    .quick-add-form select {
        flex-basis: 85px;
        width: 85px;
    }

}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition: none !important;
    }

}

/* =========================================
   21. AUTHENTICATION NAVIGATION
========================================= */
.nav-auth { display:flex; align-items:center; justify-content:flex-end; gap:14px; margin-left:auto; min-width:0; }
nav .nav-auth a { font-size:13px; font-weight:600; color:var(--accent); }
nav .nav-auth a:first-child::before { content:none; }
nav .nav-auth a:hover { color:var(--text); }
nav .nav-auth .profile-link { max-width:180px; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.logout-form { margin:0; }
.logout-form button { padding:7px 12px; background:transparent; color:var(--danger); border:1px solid var(--border); border-radius:6px; font-size:13px; font-weight:600; }
.logout-form button:hover { background:#ef444420; border-color:var(--danger); }

/* =========================================
   22. AUTHENTICATION AND PROFILE CARDS
========================================= */
.auth-section, .profile-section { width:100%; max-width:480px; margin:24px auto; padding:24px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:var(--radius); }
.profile-section { max-width:600px; }
.auth-section h2, .profile-section h2 { margin-bottom:20px; }
.auth-section > p { margin-top:18px; color:var(--muted); font-size:13px; text-align:center; }

/* =========================================
   23. AUTHENTICATION FORMS
========================================= */
.auth-form { display:flex; flex-direction:column; gap:16px; }
.auth-form p { display:flex; flex-direction:column; gap:5px; min-width:0; }
.auth-form label { color:var(--muted); font-size:13px; font-weight:600; }
.auth-form input:not([type="hidden"]) { height:38px; padding:8px 10px; }
.auth-form .helptext { display:block; line-height:1.5; }
.auth-form .helptext ul, .auth-form > ul:not(.errorlist) { margin:5px 0; padding-left:18px; color:var(--muted); font-size:12px; }
.auth-form button[type="submit"] { display:inline-flex; align-items:center; justify-content:center; min-height:38px; padding:9px 15px; background:var(--primary); color:white; border:1px solid transparent; border-radius:6px; font-weight:600; transition:background 0.15s; }
.auth-form button[type="submit"]:hover { background:#6d28d9; }

/* =========================================
   24. PROFILE DETAILS
========================================= */
.profile-header { margin-bottom:18px; padding:16px; background:var(--input); border:1px solid var(--border); border-radius:var(--radius); }
.profile-header h3 { color:var(--text); font-size:22px; font-weight:700; overflow-wrap:anywhere; }
.profile-header span { display:block; margin-top:4px; color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.profile-details { display:flex; flex-direction:column; }
.profile-details p { display:grid; grid-template-columns:140px minmax(0,1fr); gap:12px; padding:12px 0; border-bottom:1px solid var(--border); color:var(--text); overflow-wrap:anywhere; }
.profile-details strong { color:var(--muted); font-size:13px; font-weight:600; }
.profile-details p:last-child { border-bottom:none; }

/* =========================================
   25. PROFILE AND FORM ACTIONS
========================================= */
.profile-section .profile-actions, .auth-form .form-actions { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-top:8px; }
.profile-section .profile-actions { margin-top:20px; }
.profile-actions a, .auth-form .form-actions a { display:inline-flex; align-items:center; justify-content:center; min-height:38px; padding:9px 15px; background:var(--input); color:var(--accent); border:1px solid var(--border); border-radius:6px; font-size:13px; font-weight:600; transition:background 0.15s; }
.profile-actions a:first-child { background:var(--primary); color:white; border-color:transparent; }
.profile-actions a:first-child:hover { background:#6d28d9; }
.profile-actions a:hover, .auth-form .form-actions a:hover { border-color:var(--accent); text-decoration:none; }
.auth-form .form-actions button { flex:1; }

/* =========================================
   26. DJANGO MESSAGES
========================================= */
.container > .message { margin-bottom:16px; padding:10px 14px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:var(--radius); font-size:13px; }
.container > .message.success { background:#4ade8010; color:var(--success); border-color:#4ade8040; }
.container > .message.error { background:#f8717110; color:var(--danger); border-color:#f8717140; }
.container > .message.warning { background:#fbbf2410; color:var(--warning); border-color:#fbbf2440; }
.container > .message.info { background:#60a5fa10; color:var(--info); border-color:#60a5fa40; }

/* =========================================
   27. RESPONSIVE AUTHENTICATION
========================================= */
@media (max-width:600px) {
 nav:has(.nav-auth) { flex-wrap:wrap; gap:10px; }
 .nav-auth { gap:10px; }
 nav .nav-auth .profile-link { max-width:120px; }
 .auth-section, .profile-section { margin:18px auto; padding:18px; }
 .profile-details p { grid-template-columns:110px minmax(0,1fr); gap:8px; }
}
@media (max-width:380px) {
 .profile-details p { grid-template-columns:minmax(0,1fr); gap:4px; }
 .profile-section .profile-actions, .auth-form .form-actions { flex-direction:column; align-items:stretch; }
 .nav-auth { flex-wrap:wrap; }
}
