/* =========================
   PLANIFICACIÓN
========================= */

.plan-page {
    padding: 72px 0 90px;
}

.plan-page [hidden] {
    display: none !important;
}

.plan-header {
    max-width: 720px;
    margin-bottom: 32px;
}

.plan-header h1 {
    margin-top: 14px;
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1.04;
    letter-spacing: -2px;
}

.plan-header p:last-child {
    max-width: 620px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 17px;
}

.plan-gate {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}

/* ---------- Objetivo y avisos ---------- */

.plan-goal {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 16px 20px;
    background: rgba(184, 255, 61, 0.06);
    border: 1px solid rgba(184, 255, 61, 0.28);
    border-radius: var(--radius);
}

.plan-goal__icon {
    font-size: 24px;
}

.plan-goal__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
}

.plan-goal__text span {
    color: var(--muted);
    font-size: 14px;
}

.plan-goal__link {
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

.plan-goal__link:hover {
    text-decoration: underline;
}

.plan-notice {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 10px;
    color: #ffd666;
    font-size: 14px;
}

/* ---------- Barra de herramientas ---------- */

.plan-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.plan-nav,
.plan-toolbar__right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.plan-range {
    margin-left: 8px;
    font-size: 22px;
    letter-spacing: -0.5px;
}

/* ---------- Botones (mismo estilo que el resto de la web) ---------- */

.primary-button,
.plan-ghost-button,
.plan-icon-button,
.plan-danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        opacity 0.18s ease;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.primary-button {
    background: var(--accent);
    color: #090b0d;
    border: 1px solid rgba(184, 255, 61, 0.8);
    box-shadow: 0 4px 10px rgba(184, 255, 61, 0.08);
}

.primary-button:hover {
    transform: translateY(-1px);
    background: #c3f65a;
    border-color: rgba(184, 255, 61, 0.85);
    box-shadow: 0 4px 10px rgba(184, 255, 61, 0.06);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 6px rgba(9, 11, 13, 0.12);
}

.plan-ghost-button,
.plan-icon-button {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.plan-ghost-button:hover,
.plan-icon-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.04);
    border-color: #3b424c;
}

.plan-icon-button {
    width: 44px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

.plan-danger-button {
    background: rgba(255, 107, 107, 0.07);
    color: #ffb4b4;
    border: 1px solid rgba(255, 107, 107, 0.28);
    box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.04);
}

.plan-danger-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.4);
}

.primary-button:focus-visible,
.plan-ghost-button:focus-visible,
.plan-icon-button:focus-visible,
.plan-danger-button:focus-visible,
.plan-switch__button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.primary-button:disabled,
.plan-ghost-button:disabled,
.plan-icon-button:disabled,
.plan-danger-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.plan-switch {
    display: inline-flex;
    padding: 3px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.plan-switch__button {
    min-height: 36px;
    padding: 6px 16px;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.plan-switch__button:hover {
    color: var(--text);
}

.plan-switch__button[aria-pressed="true"] {
    background: var(--accent);
    color: #090b0d;
}

/* ---------- Resumen ---------- */

.plan-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.plan-stat {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.plan-stat h3 {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.plan-stat__value {
    margin-top: 8px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.plan-stat__sub {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.plan-bar {
    height: 6px;
    margin-top: 12px;
    overflow: hidden;
    background: var(--surface-light);
    border-radius: 99px;
}

.plan-bar span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ---------- Consejos de la semana ---------- */

.plan-tips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.plan-tip {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;

    background: rgba(255, 193, 7, 0.06);
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: 10px;

    color: var(--text);
    font-size: 14px;
}

.plan-tip.is-good {
    background: rgba(184, 255, 61, 0.05);
    border-color: rgba(184, 255, 61, 0.25);
}

.plan-tip__icon {
    flex: none;
    line-height: 1.5;
}

.plan-tip small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Vista semanal ---------- */

.plan-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.plan-day {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 260px;
    padding: 12px 10px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.plan-day.is-today {
    border-color: var(--accent);
}

.plan-day.is-goal {
    background: rgba(184, 255, 61, 0.05);
}

.plan-day.is-over,
.plan-mday.is-over {
    border-color: var(--accent);
    background: rgba(184, 255, 61, 0.1);
}

.plan-day__head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    text-transform: capitalize;
}

.plan-day__num {
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
}

.plan-day.is-today .plan-day__num {
    color: var(--accent);
}

.plan-day__list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
}

.plan-day__empty {
    color: #4a525d;
    font-size: 12px;
}

.plan-day__add {
    align-self: stretch;
    padding: 6px;
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.plan-day:hover .plan-day__add,
.plan-day__add:focus-visible {
    opacity: 1;
}

.plan-day__add:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Actividad ---------- */

.plan-activity {
    --c: #4ade80;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--c);
    border-radius: 10px;
    cursor: grab;
    transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.plan-activity:hover {
    transform: translateY(-1px);
    border-color: #3b424c;
    border-left-color: var(--c);
}

.plan-activity:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.plan-activity.is-dragging {
    opacity: 0.4;
}

.plan-activity.is-done {
    background: color-mix(in srgb, var(--c) 12%, var(--bg));
}

.plan-activity.is-skipped {
    opacity: 0.55;
}

.plan-activity.is-skipped .plan-activity__title {
    text-decoration: line-through;
}

.plan-activity__icon {
    flex: none;
    font-size: 14px;
    line-height: 1.4;
}

.plan-activity.is-done .plan-activity__icon {
    color: var(--c);
    font-weight: 900;
}

.plan-activity__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.plan-activity__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
}

.plan-activity__meta {
    color: var(--muted);
    font-size: 12px;
}

.plan-activity__target {
    color: var(--muted);
    font-size: 11px;
    opacity: 0.85;
}

.plan-activity__check {
    flex: none;
    width: 24px;
    height: 24px;
    background: transparent;
    color: transparent;
    border: 2px solid var(--border);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.plan-activity__check:hover {
    border-color: var(--c);
    color: var(--c);
}

.plan-activity__check.is-on {
    background: var(--c);
    border-color: var(--c);
    color: #090b0d;
}

.plan-activity.is-compact {
    padding: 4px 6px;
    gap: 5px;
    border-radius: 6px;
}

.plan-activity.is-compact .plan-activity__title {
    font-size: 11px;
}

.plan-activity.is-compact .plan-activity__icon {
    font-size: 11px;
}

/* ---------- Vista mensual ---------- */

.plan-month__head,
.plan-month__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.plan-month__head {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.plan-mday {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 104px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.plan-mday.is-other {
    opacity: 0.45;
}

.plan-mday.is-today {
    border-color: var(--accent);
}

.plan-mday.is-goal {
    background: rgba(184, 255, 61, 0.06);
}

.plan-mday__num {
    align-self: flex-start;
    padding: 0 2px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.plan-mday__num:hover,
.plan-mday.is-today .plan-mday__num {
    color: var(--accent);
}

.plan-mday__list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.plan-mday__more {
    align-self: flex-start;
    padding: 0 2px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
}

.plan-mday__more:hover {
    color: var(--accent);
}

/* ---------- Semanas ---------- */

.plan-weeks {
    margin-top: 28px;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.plan-weeks__heading h2 {
    font-size: 22px;
    letter-spacing: -0.5px;
}

.plan-weeks__heading p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.plan-weeks__chart {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.plan-weekbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

.plan-weekbar:hover {
    background: rgba(255, 255, 255, 0.03);
}

.plan-weekbar.is-selected {
    border-color: var(--accent);
}

.plan-weekbar.is-current .plan-weekbar__label {
    color: var(--accent);
}

.plan-weekbar__value {
    color: var(--muted);
    font-size: 11px;
}

.plan-weekbar__bars {
    position: relative;
    width: 100%;
    max-width: 44px;
    height: 110px;
    background: var(--surface-light);
    border-radius: 8px;
    overflow: hidden;
}

.plan-weekbar__planned,
.plan-weekbar__done {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    transition: height 0.4s ease;
}

.plan-weekbar__planned {
    background: rgba(184, 255, 61, 0.22);
}

.plan-weekbar__done {
    left: 22%;
    width: 56%;
    background: var(--accent);
    border-radius: 6px 6px 0 0;
}

.plan-weekbar__label {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

/* ---------- Diálogo ---------- */

.plan-dialog {
    inset: 0;
    margin: auto;
    width: min(560px, 94vw);
    max-height: 92vh;
    padding: 26px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.plan-dialog::backdrop {
    background: rgba(0, 0, 0, 0.68);
}

.plan-dialog h2 {
    margin-bottom: 18px;
    font-size: 22px;
    letter-spacing: -0.5px;
}

.plan-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.plan-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.plan-field--full {
    grid-column: 1 / -1;
}

.plan-field label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.plan-optional {
    font-weight: 400;
    opacity: 0.7;
}

.plan-field input,
.plan-field select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.plan-field input:focus,
.plan-field select:focus {
    outline: none;
    border-color: var(--accent);
}

.plan-done-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    background: rgba(184, 255, 61, 0.05);
    border: 1px solid rgba(184, 255, 61, 0.2);
    border-radius: 12px;
}

.plan-hint {
    padding: 12px 14px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.plan-hint strong {
    color: var(--text);
}

.plan-hint a {
    color: var(--accent);
    font-weight: 700;
}

.plan-hint__use {
    padding: 2px 10px;
    background: rgba(184, 255, 61, 0.12);
    color: var(--accent);
    border: 1px solid rgba(184, 255, 61, 0.35);
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.plan-error {
    margin-top: 14px;
    color: var(--danger);
    font-size: 14px;
}

.plan-dialog__actions {
    display: flex;
    gap: 8px;
    margin-top: 22px;
}

.plan-dialog__actions .primary-button {
    margin-left: auto;
}

/* ---------- Aviso emergente ---------- */

.plan-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 80;
    max-width: calc(100vw - 32px);
    padding: 12px 22px;
    background: var(--accent);
    color: #090b0d;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    transform: translate(-50%, 140px);
    transition: transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.plan-toast.is-visible {
    transform: translate(-50%, 0);
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    .plan-week {
        grid-template-columns: 1fr;
    }

    .plan-day {
        min-height: 0;
    }

    .plan-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .plan-page {
        padding-top: 48px;
    }

    .plan-form-grid,
    .plan-done-fields {
        grid-template-columns: 1fr;
    }

    .plan-weeks__chart {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .plan-weeks {
        padding: 20px 16px;
    }

    .plan-mday {
        min-height: 70px;
        padding: 4px;
    }

    .plan-mday .plan-activity__title {
        display: none;
    }

    .plan-mday .plan-activity.is-compact {
        padding: 2px;
        justify-content: center;
    }

    .plan-range {
        flex-basis: 100%;
        margin: 6px 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .plan-toast,
    .plan-bar span,
    .plan-weekbar__planned,
    .plan-weekbar__done {
        transition: none;
    }
}

/* ---------- Objetivos diarios dentro de la planificación ---------- */

.plan-habits {
    margin-top: 28px;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.plan-habits__heading {
    margin-bottom: 18px;
}

.plan-habits__heading h2 {
    font-size: 22px;
    letter-spacing: -0.5px;
}

.plan-habits__heading p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 700px) {
    .plan-habits {
        padding: 20px 16px;
    }
}
