/* ═══ sections.css — Main Layout, Sections, Cards, Forms ═══ */

/* ═══ MAIN ═══ */
.main {
    margin-left: 240px;
    flex: 1;
    padding: var(--space-6);
    max-width: calc(100% - 240px);
    overflow-x: hidden;
    background: var(--background);
    transition: margin-left var(--dur) var(--ease), max-width var(--dur) var(--ease);
    will-change: margin-left;
}
body.sidebar-collapsed .main {
    margin-left: 48px;
    max-width: calc(100% - 48px);
}

.main-content {
    padding: var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
}

/* ═══ TOP BAR (sticky header) ═══ */
.top-bar,
.topbar {
    height: 56px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
}

.section { display: none; contain: content; /* transition handled by GSAP (animarCambioSeccion) */ }
.section.active { display: block; }
.section.active.fade-in { opacity: 1; }

/* ═══ INICIO: layout mosaico ═══ */
#sec-inicio.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--sp-6));
    overflow: visible;
    gap: var(--sp-4);
}
#sec-inicio .header-banner,
#sec-inicio .dashboard-hero {
    margin-bottom: var(--space-6);
    flex-shrink: 0;
}
/* KPI cards mosaico */
#sec-inicio .cards-grid {
    margin-bottom: 0;
    gap: var(--sp-3);
    flex-shrink: 0;
}
#sec-inicio .metric-card {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-3);
}
#sec-inicio .metric-card .label { margin-bottom: var(--sp-1); }
#sec-inicio .metric-card .value { font-size: 1.5rem; }

/* ═══ Dashboard KPI Proyecto ═══ */
.project-kpi-dashboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    /* fadeIn → replaced by GSAP */
}
.project-kpi-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-3);
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    box-shadow: var(--shadow-2), var(--glass-highlight);
    transition: all var(--dur) var(--ease);
}
.project-kpi-card:hover {
    border-color: var(--border2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-3), var(--glass-highlight);
}
.project-kpi-card .kpi-label {
    font-size: .62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text3);
    font-family: var(--mono);
}
.project-kpi-card .kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1;
    margin: var(--sp-1) 0;
}
.project-kpi-card .kpi-detail {
    font-size: .6rem;
    color: var(--text3);
    font-family: var(--mono);
}
.project-kpi-card .kpi-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--r-pill);
    overflow: hidden;
    margin-top: var(--sp-1);
    display: flex;
}
.project-kpi-card .kpi-bar-fill {
    height: 100%;
    border-radius: var(--r-pill);
    transition: width 0.8s var(--ease);
    box-shadow: 0 0 8px currentColor;
    flex-shrink: 0;
}
.project-kpi-card.kpi-avance .kpi-value { color: var(--claude); }
.project-kpi-card.kpi-avance .kpi-bar-fill { background: var(--claude); }
.project-kpi-card.kpi-docs .kpi-bar-fill { background: var(--green); }
.project-kpi-card.kpi-hh .kpi-bar-fill { background: var(--blue); }
.project-kpi-card.kpi-pending .kpi-value { color: var(--yellow); }
@media (max-width: 900px) {
    .project-kpi-dashboard { grid-template-columns: 1fr 1fr; }
    .proyecto-body > div[style*="grid-template-columns:repeat(3"] { grid-template-columns: 1fr 1fr !important; }
    .proyecto-body > div[style*="grid-template-columns:repeat(4"] { grid-template-columns: 1fr 1fr !important; }
}

/* Zona de mosaicos — flex vertical con filas */
#sec-inicio .inicio-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#sec-inicio .inicio-body > .grid-2 {
    flex: 1;
    min-height: 60px;
    margin-bottom: 0;
    gap: var(--sp-4);
    overflow: visible;
}
#sec-inicio .inicio-body > .grid-2 > .panel {
    overflow: hidden;
    min-width: 60px;
}
/* Paneles mosaico */
#sec-inicio .inicio-body .panel.panel-accordion {
    border-radius: var(--r-3);
    margin: 0;
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), z-index 0s 0.25s, border-color var(--dur) var(--ease);
}
#sec-inicio .inicio-body .panel.panel-accordion > .panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: var(--sp-1);
}
/* Hover: elevar mosaico */
#sec-inicio .inicio-body .panel.panel-accordion:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-3), var(--glass-highlight);
    border-color: var(--border2);
    z-index: 20;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), z-index 0s 0s;
}

/* ═══ HOVER EXPAND: detalle al pasar cursor ═══ */
#sec-inicio .email-item .email-preview {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.25s ease;
    font-size: 0.74rem;
    color: var(--text3);
    line-height: 1.45;
    margin-top: 0;
}
#sec-inicio .email-item:hover .email-preview {
    max-height: 120px;
    opacity: 1;
    margin-top: 6px;
}
#sec-inicio .email-item .email-preview .preview-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text2);
}
/* Home HH Summary */
.home-hh-summary {
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--claude);
    border-radius: var(--r-2);
    margin-bottom: var(--sp-3);
}
.home-hh-summary .hh-stat {
    flex: 1;
    text-align: center;
    padding: var(--sp-1) var(--sp-2);
    border-right: 1px solid var(--glass-border);
}
.home-hh-summary .hh-stat:last-child { border-right: none; }
.home-hh-summary .hh-val {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.1;
}
.home-hh-summary .hh-lbl {
    font-size: 0.58rem;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: var(--sp-1);
    font-family: var(--mono);
}

#sec-inicio .week-day-row .week-detail {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    font-size: 0.72rem;
    color: var(--text3);
    width: 100%;
}
#sec-inicio .week-day-row:hover .week-detail {
    max-height: 80px;
    opacity: 1;
}
#sec-inicio .week-day-row {
    flex-wrap: wrap;
}
#sec-inicio .week-detail .detail-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 0.7rem;
}
#sec-inicio .week-detail .detail-pill i {
    font-size: 0.6rem;
    color: var(--claude3);
}
#sec-inicio .week-detail .detail-pill .detail-resp {
    color: var(--blue);
    font-size: 0.65rem;
}
#sec-inicio .week-detail .detail-pill .detail-hrs {
    color: var(--green);
    font-size: 0.65rem;
}

/* ═══ HEADER ═══ */
/* ═══ HERO BANNER (dashboard home) — shadcn + parallax ═══ */
.dashboard-hero, .header-banner {
    position: relative;
    padding: var(--space-10) var(--space-6);
    margin: 0 0 var(--space-6);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    min-height: 160px;
    display: flex;
    align-items: center;
}
.dashboard-hero .hero-content,
.header-banner .hero-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.hero-greeting, .header-banner h1 {
    font-size: 2rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1.1;
}
.hero-subtitle, .header-banner p {
    font-size: var(--font-size-base);
    color: var(--text-muted);
    font-family: var(--font-sans);
    letter-spacing: 0;
}
.dashboard-hero .hero-bg,
.header-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 85% 40%, var(--bg-muted) 0%, transparent 55%),
        radial-gradient(circle at 15% 80%, var(--bg-hover) 0%, transparent 45%);
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
}

/* ═══ KPI CARDS ═══ */
.metric-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-3);
    padding: var(--sp-4) var(--sp-5);
    transition: all var(--dur) var(--ease);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-2), var(--glass-highlight);
}

.metric-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(212, 165, 116, 0.04) 100%);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    pointer-events: none;
}

.metric-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--claude), var(--claude3));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur) var(--ease);
}

.metric-card:hover {
    border-color: var(--border2);
    transform: translateY(-4px);
    box-shadow: var(--shadow-3), var(--glass-highlight);
}
.metric-card:hover::before { opacity: 1; }
.metric-card:hover::after { transform: scaleX(1); }

.metric-card .label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--sp-2);
    font-family: var(--mono);
    position: relative;
    z-index: 1;
}

.metric-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.1;
    position: relative;
    z-index: 1;
}

.metric-card .value.emails { color: var(--blue); font-size: 0.85rem; }
.metric-card .value.tasks { color: var(--green); }
.metric-card .value.notes { color: var(--purple); }

/* Staggered card animation → replaced by GSAP (animarCards) */

/* ═══ PANELS (mosaico) ═══ */
.panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-3);
    padding: var(--sp-5);
    margin-bottom: var(--sp-4);
    box-shadow: var(--shadow-2), var(--glass-highlight);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.panel:hover {
    border-color: var(--border2);
    box-shadow: var(--shadow-3), var(--glass-highlight);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--glass-border);
}

.panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.panel-title i { color: var(--claude); font-size: 0.9rem; text-shadow: 0 0 10px rgba(212,165,116,0.3); }

.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }

/* Staggered panel animation → replaced by GSAP (animarCards) */

/* ═══ BUTTONS ═══ */
.btn {
    padding: var(--sp-2) var(--sp-4);
    min-height: 34px;
    border: 1px solid var(--glass-border);
    border-radius: var(--r-2);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem;
    font-family: var(--sans);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text2);
    transition: all var(--dur-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, var(--claude-glow), transparent 70%);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    pointer-events: none;
}
.btn:hover {
    border-color: var(--border2);
    color: var(--text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}
.btn:hover::after { opacity: 0.15; }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-claude {
    background: linear-gradient(135deg, var(--claude) 0%, var(--claude3) 100%);
    color: #1a1208;
    border-color: transparent;
    font-weight: 600;
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-claude:hover {
    color: #1a1208;
    transform: translateY(-1px);
    box-shadow: var(--shadow-3), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-green {
    color: var(--green);
    border-color: rgba(126, 198, 153, 0.25);
    background: rgba(126, 198, 153, 0.08);
}
.btn-green:hover {
    background: rgba(126, 198, 153, 0.15);
    border-color: var(--green);
    color: var(--green);
}

/* ═══ INPUTS ═══ */
.input-field {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-2);
    color: var(--text);
    font-size: 0.82rem;
    font-family: var(--sans);
    transition: all var(--dur-fast) var(--ease);
}

.input-field:focus {
    outline: none;
    border-color: var(--claude);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px var(--claude-glow);
}

.input-field::placeholder { color: var(--text3); }
textarea.input-field { resize: vertical; min-height: 72px; line-height: 1.5; }
select.input-field {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23A39985' d='M2 4l4 4 4-4z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: var(--sp-6);
}

/* ═══ EMAIL ═══ */
.email-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    border-left: 2px solid transparent;
    border-radius: 2px;
}

.email-item:last-child { border-bottom: none; }
.email-icon { font-size: 0.9em; margin-top: 3px; min-width: 18px; }
.email-info { flex: 1; min-width: 0; }

.email-subject {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--sans);
}

.email-from { font-size: 0.78rem; color: var(--text3); }

.email-date {
    font-size: 0.72rem;
    color: var(--text3);
    white-space: nowrap;
    min-width: 120px;
    text-align: right;
    font-family: var(--mono);
}

/* ═══ EMAIL READER ═══ */
.email-reader-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 999;
    display: none; justify-content: center; align-items: center;
}
.email-reader-overlay.active { display: flex; }

.email-reader {
    background: var(--bg2); border: 1px solid var(--border2);
    border-radius: 2px; width: 90%; max-width: 800px;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.reader-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg3); border-radius: 2px 8px 0 0;
}

.reader-header .reader-title {
    font-size: 0.85rem; color: var(--claude);
}

.reader-close {
    background: none; border: none; color: var(--text2);
    cursor: pointer; font-size: 1.1rem; padding: 4px 8px;
    border-radius: 2px; transition: 0.15s;
}
.reader-close:hover { background: var(--surface); color: var(--red); }

.reader-meta {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-size: 0.82rem; font-family: var(--sans);
}
.reader-meta .meta-row { display: flex; gap: 8px; margin-bottom: 4px; }
.reader-meta .meta-label { color: var(--text3); min-width: 50px; font-size: 0.78rem; }
.reader-meta .meta-value { color: var(--text); }
.reader-subject {
    font-size: 1rem; font-weight: 600; color: var(--text);
    margin-bottom: 8px; font-family: var(--sans);
}

.reader-body {
    padding: 16px; overflow-y: auto; flex: 1;
    font-family: var(--sans); font-size: 0.88rem;
    line-height: 1.7; color: var(--text);
}
.reader-body img { max-width: 100%; height: auto; }
.reader-body a { color: var(--blue); }
.reader-body blockquote {
    border-left: 3px solid var(--claude3); padding-left: 12px;
    margin: 8px 0; color: var(--text2);
}

.reader-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; color: var(--text2); font-size: 0.85rem;
}

/* ═══ TASKS ═══ */
.task-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.task-item input[type=checkbox] { width: 13px; height: 13px; cursor: pointer; accent-color: var(--claude); flex-shrink: 0; }
#home-tasks .task-item { padding: 3px 5px; gap: 5px; font-size: 0.74rem; line-height: 1.3; }
#home-tasks .task-item input[type=checkbox] { width: 12px; height: 12px; }
.task-done { text-decoration: line-through; color: var(--text3); }

.task-delete {
    cursor: pointer;
    color: var(--text3);
    opacity: 0.4;
    transition: 0.15s;
    margin-left: auto;
    font-size: 0.8rem;
}

.task-delete:hover { opacity: 1; color: var(--red); }

.task-resp {
    font-size: 0.7rem;
    color: var(--cyan);
    background: rgba(112, 200, 212, 0.1);
    padding: 1px 7px;
    border-radius: 2px;
    margin-left: auto;
    white-space: nowrap;
    font-family: var(--mono);
}

.task-date-tag {
    font-size: 0.65rem;
    color: var(--blue);
    background: rgba(108, 172, 222, 0.1);
    padding: 1px 7px;
    border-radius: 2px;
    white-space: nowrap;
    font-family: var(--mono);
    margin-left: 4px;
}

.task-date-tag.unscheduled {
    color: var(--text3);
    background: rgba(107, 99, 88, 0.15);
    font-style: italic;
}

.task-hours {
    font-size: 0.62rem;
    padding: 1px 6px;
    border-radius: 2px;
    margin-left: 4px;
    font-family: var(--mono);
    white-space: nowrap;
}
.task-hours.projected {
    color: var(--yellow);
    background: rgba(224, 192, 112, 0.1);
}
.task-hours.completed {
    color: var(--green);
    background: rgba(126, 198, 153, 0.1);
}
.task-hours.over {
    color: var(--red);
    background: rgba(224, 108, 96, 0.1);
}

.chip-hours {
    font-size: 0.52rem;
    color: var(--yellow);
    opacity: 0.8;
    margin-left: 3px;
    font-family: var(--mono);
}

.chip-resp {
    font-size: 0.6rem;
    color: var(--cyan);
    opacity: 0.8;
    margin-left: 4px;
    font-family: var(--mono);
}

/* ═══ NOTES ═══ */
.note-card {
    background: var(--bg2);
    border-radius: 2px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-left: 2px solid var(--claude3);
    position: relative;
}

.note-card p { font-size: 0.85rem; margin-bottom: 4px; word-break: break-word; font-family: var(--sans); color: var(--text); }
.note-card small { color: var(--text3); font-size: 0.72rem; font-family: var(--mono); }

.note-delete {
    cursor: pointer;
    color: var(--text3);
    opacity: 0.4;
    transition: 0.15s;
    float: right;
    margin-left: 8px;
}

.note-delete:hover { opacity: 1; color: var(--red); }
