/* ============================================================
   TaskFlow — Hoja de estilos principal
   Estética: Editorial industrial / Tipografía prominente
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

/* ── Variables ──────────────────────────────────────── */
:root {
    --bg:           #f4f3ef;
    --surface:      #ffffff;
    --surface-alt:  #f9f8f5;
    --border:       #e5e2d9;
    --border-strong:#c9c4b8;
    --text:         #1a1916;
    --text-secondary:#6b6760;
    --muted:        #9e9a93;
    --accent:       #4f46e5;
    --accent-dark:  #3730a3;
    --accent-light: #eef2ff;
    --danger:       #dc2626;
    --danger-light: #fee2e2;
    --success:      #059669;
    --warning:      #d97706;
    --sidebar-w:    260px;
    --radius:       14px;
    --radius-sm:    8px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:    0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:    0 20px 40px rgba(0,0,0,.12);
    --transition:   .2s ease;
}

/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.wordmark {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--accent);
    letter-spacing: -.03em;
    margin-bottom: .75rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-name {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem;
}

.nav-section-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 0 .5rem;
    margin-bottom: .5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
    cursor: pointer;
}

.nav-item:hover { background: var(--surface-alt); color: var(--text); }

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon { font-size: .9rem; flex-shrink: 0; opacity: .7; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-delete {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 1.1rem; line-height: 1;
    padding: 2px 4px; border-radius: 4px;
    opacity: 0; transition: opacity var(--transition), color var(--transition);
}
.nav-item:hover .nav-delete { opacity: 1; }
.nav-delete:hover { color: var(--danger); }

.nav-empty {
    font-size: .82rem;
    color: var(--muted);
    padding: .5rem .5rem;
    font-style: italic;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.btn-sidebar {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: .85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-sidebar:hover {
    background: var(--surface-alt);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-sidebar--logout { color: var(--danger); }
.btn-sidebar--logout:hover { background: var(--danger-light); border-color: #fca5a5; }

/* ── Main content ───────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

/* Board header */
.board-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.board-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.6rem;
    letter-spacing: -.03em;
    color: var(--text);
    line-height: 1.15;
}

.board-subtitle {
    font-size: .8rem;
    color: var(--muted);
    margin-top: 3px;
}

.board-actions { display: flex; gap: .6rem; align-items: center; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}
.btn--primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-alt); }

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--surface-alt); }

/* ── Kanban Board ───────────────────────────────────── */
.kanban-board {
    flex: 1;
    display: flex;
    gap: 1rem;
    padding: 1.25rem 1.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--bg);
}

.kanban-col {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    max-height: 100%;
    transition: box-shadow var(--transition);
}

.kanban-col.drag-over {
    box-shadow: 0 0 0 2px var(--accent), var(--shadow-md);
}

.col-header {
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    flex-shrink: 0;
}

.col-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
}

.col-icon { font-size: 1rem; }

.col-count {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.col-body {
    flex: 1;
    overflow-y: auto;
    padding: .75rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.col-empty {
    flex: 1;
    min-height: 80px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    color: var(--muted);
    font-weight: 500;
}

/* ── Task Card ──────────────────────────────────────── */
.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .85rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.task-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.task-card:active { transform: scale(.98); cursor: grabbing; }

.task-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .4rem;
    margin-bottom: .4rem;
}

.task-title {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    flex: 1;
}

.task-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
    flex-shrink: 0;
}
.task-card:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--danger); }

.task-desc {
    font-size: .8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: .6rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    flex-wrap: wrap;
}

.task-date {
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 6px;
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid #c7d2fe;
    padding: 2px 8px 2px 4px;
    border-radius: 20px;
}

.assignee-avatar {
    width: 18px; height: 18px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: .62rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3.5rem;
    color: var(--border-strong);
    margin-bottom: 1rem;
    font-family: 'DM Serif Display', serif;
}

.empty-state h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: .5rem;
}

.empty-state p {
    font-size: .9rem;
    max-width: 340px;
    margin-bottom: 1.5rem;
}

/* ── Modals ─────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 25, 22, .45);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modal-in .18s ease;
}

.modal--sm { max-width: 380px; }

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

.modal-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-alt);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.15rem;
    color: var(--text);
    letter-spacing: -.02em;
}

.modal-close {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 28px; height: 28px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    line-height: 1;
}
.modal-close:hover { background: var(--danger-light); border-color: #fca5a5; color: var(--danger); }

.modal form { padding: 1.25rem 1.5rem 1.5rem; }

.modal-footer {
    display: flex;
    gap: .6rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.modal-footer .btn { flex: 1; justify-content: center; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .35rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}

.form-group textarea { resize: vertical; min-height: 70px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

/* ── Team members ───────────────────────────────────── */
#team-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }

.team-member {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}

.member-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-info strong { display: block; font-size: .88rem; color: var(--text); }
.member-info small  { font-size: .75rem; color: var(--muted); }

.member-delete {
    background: none; border: none;
    cursor: pointer; color: var(--muted);
    font-size: 1.1rem; padding: 2px 5px;
    border-radius: 4px; transition: color var(--transition);
}
.member-delete:hover { color: var(--danger); }

/* ── Toast ──────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--text);
    color: #fff;
    padding: .65rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    z-index: 999;
    box-shadow: var(--shadow-lg);
    transform: translateY(120%);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast--error { background: var(--danger); }
.toast--success { background: var(--success); }

/* ── AI / Gemini Buttons ─────────────────────────────── */
.btn--ai {
    background: linear-gradient(135deg, #6d28d9, #7c3aed, #8b5cf6);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(109,40,217,.35);
    position: relative;
    overflow: hidden;
}

.btn--ai::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #7c3aed, #a78bfa, #7c3aed);
    opacity: 0;
    transition: opacity .3s;
}

.btn--ai:hover::before { opacity: 1; }
.btn--ai:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(109,40,217,.45); }
.btn--ai:active { transform: scale(.97); }
.btn--ai:disabled { opacity: .65; pointer-events: none; }

.btn--ai > * { position: relative; z-index: 1; }

.btn-ai-icon {
    font-size: .9rem;
    animation: ai-pulse 2.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes ai-pulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50%       { transform: scale(1.2) rotate(15deg); opacity: .85; }
}

/* Inline AI button inside task modal */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .35rem;
}

.label-row label { margin-bottom: 0; }

.btn-ai-inline {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: none;
    border: 1px solid #c4b5fd;
    color: #7c3aed;
    font-size: .75rem;
    font-weight: 600;
    font-family: inherit;
    padding: 3px 9px;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-ai-inline:hover {
    background: #f5f3ff;
    border-color: #8b5cf6;
    color: #6d28d9;
}

.btn-ai-inline:disabled { opacity: .5; pointer-events: none; }

.ai-inline-icon {
    font-size: .8rem;
    animation: ai-pulse 2.5s ease-in-out infinite;
    display: inline-block;
}

/* API Key hint box */
.ai-key-hint {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius-sm);
    padding: .65rem .85rem;
    font-size: .8rem;
    color: #5b21b6;
    line-height: 1.45;
}

.ai-key-hint a {
    color: #7c3aed;
    font-weight: 600;
    text-decoration: underline;
}

/* Error block inside suggest modal */
.ai-error {
    background: var(--danger-light);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    color: var(--danger);
    padding: .65rem .85rem;
    font-size: .82rem;
    margin-top: .75rem;
    line-height: 1.45;
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 50;
        transition: left var(--transition);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .kanban-board { padding: 1rem; }
    .board-header { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
}
