/* ==========================================================================
   Daily Task Tracker – Stylesheet
   Covers: admin pages, frontend shortcodes, calendar, progress bar, popover.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (tokens)
   -------------------------------------------------------------------------- */
:root {
    --dtt-primary:        #4f46e5;   /* indigo-600   */
    --dtt-primary-hover:  #4338ca;   /* indigo-700   */
    --dtt-success:        #22c55e;   /* green-500    */
    --dtt-success-dark:   #16a34a;   /* green-600    */
    --dtt-warning:        #f59e0b;   /* amber-400    */
    --dtt-warning-dark:   #d97706;   /* amber-600    */
    --dtt-danger:         #ef4444;   /* red-500      */
    --dtt-surface:        #ffffff;
    --dtt-surface-2:      #f8fafc;
    --dtt-border:         #e2e8f0;
    --dtt-text:           #1e293b;
    --dtt-text-muted:     #64748b;
    --dtt-radius:         8px;
    --dtt-shadow:         0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --dtt-shadow-lg:      0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --dtt-transition:     all .2s ease;
}

/* --------------------------------------------------------------------------
   Admin – Wrap
   -------------------------------------------------------------------------- */
.dtt-admin-wrap {
    max-width: 1200px;
}

.dtt-admin-wrap h1.wp-heading-inline {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dtt-text);
}

/* --------------------------------------------------------------------------
   Admin – Filters toolbar
   -------------------------------------------------------------------------- */
.dtt-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    padding: 12px 16px;
    background: var(--dtt-surface);
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
}

.dtt-filters label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--dtt-text);
    font-weight: 500;
}

.dtt-filters input[type="date"],
.dtt-filters select {
    border: 1px solid var(--dtt-border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--dtt-text);
    background: var(--dtt-surface);
    transition: var(--dtt-transition);
}

.dtt-filters input[type="date"]:focus,
.dtt-filters select:focus {
    outline: none;
    border-color: var(--dtt-primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,.2);
}

/* --------------------------------------------------------------------------
   Admin – Task table badges
   -------------------------------------------------------------------------- */
.dtt-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dtt-badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.dtt-badge-done {
    background: #d1fae5;
    color: #065f46;
}

/* --------------------------------------------------------------------------
   Admin – Add/Edit form
   -------------------------------------------------------------------------- */
.dtt-form .form-table th {
    width: 180px;
    font-weight: 600;
    color: var(--dtt-text);
}

.dtt-form input[type="text"],
.dtt-form input[type="date"],
.dtt-form input[type="email"],
.dtt-form select,
.dtt-form textarea {
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    padding: 7px 10px;
    transition: var(--dtt-transition);
}

.dtt-form input:focus,
.dtt-form select:focus,
.dtt-form textarea:focus {
    border-color: var(--dtt-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.2);
    outline: none;
}

/* --------------------------------------------------------------------------
   Statistics dashboard
   -------------------------------------------------------------------------- */
.dtt-stats-grid {
    display: grid;
    grid-template-columns: repeat( auto-fit, minmax(260px, 1fr) );
    gap: 20px;
    margin-top: 20px;
}

.dtt-stat-card {
    background: var(--dtt-surface);
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    padding: 20px 24px;
    box-shadow: var(--dtt-shadow);
}

.dtt-stat-card h2 {
    margin: 0 0 4px;
    font-size: 1.1rem;
    color: var(--dtt-text);
}

.dtt-stat-card > p {
    font-size: 12px;
    color: var(--dtt-text-muted);
    margin: 0 0 16px;
}

.dtt-stat-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    gap: 20px;
}

.dtt-stat-list li {
    font-size: 15px;
    font-weight: 600;
    color: var(--dtt-text);
}

.dtt-progress-label {
    font-size: 13px;
    color: var(--dtt-text-muted);
    margin: 6px 0 0;
}

/* --------------------------------------------------------------------------
   Progress bar  (shared admin + frontend)
   -------------------------------------------------------------------------- */
.dtt-progress-wrap {
    width: 100%;
    height: 10px;
    background: var(--dtt-border);
    border-radius: 9999px;
    overflow: hidden;
}

.dtt-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--dtt-primary) 0%, var(--dtt-success) 100%);
    border-radius: 9999px;
    transition: width .4s ease;
    min-width: 2px;
}

/* --------------------------------------------------------------------------
   Frontend – Task list wrapper
   -------------------------------------------------------------------------- */
.dtt-task-list-wrap {
    font-family: inherit;
    max-width: 640px;
}

.dtt-task-list-wrap .dtt-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.dtt-task-list-wrap .dtt-list-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dtt-text);
}

.dtt-task-list-wrap .dtt-progress-count {
    font-size: 13px;
    color: var(--dtt-text-muted);
}

.dtt-progress-section {
    margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Frontend – Task items
   -------------------------------------------------------------------------- */
.dtt-task-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dtt-task-item {
    background: var(--dtt-surface);
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--dtt-shadow);
    transition: var(--dtt-transition);
}

.dtt-task-item:hover {
    border-color: var(--dtt-primary);
    box-shadow: var(--dtt-shadow-lg);
}

.dtt-task-item.dtt-task--done {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.dtt-task-item.dtt-task--done .dtt-task-name {
    text-decoration: line-through;
    color: var(--dtt-text-muted);
}

.dtt-task-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    cursor: pointer;
    user-select: none;
}

/* Custom checkbox */
.dtt-task-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--dtt-primary);
    cursor: pointer;
    margin-top: 2px;
}

.dtt-task-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--dtt-text);
    line-height: 1.4;
}

.dtt-task-meta {
    font-size: 12px;
    color: var(--dtt-text-muted);
    margin-top: 4px;
}

.dtt-task-notes {
    font-size: 13px;
    color: var(--dtt-text-muted);
    margin-top: 6px;
    font-style: italic;
    line-height: 1.5;
}

.dtt-task-notes a {
    color: var(--dtt-primary, #4f46e5);
    text-decoration: underline;
    font-style: normal;
    word-break: break-word;
}

/* Recurring-series progress note ("Started … / N completed / N pending").
   Rendered only while the series still has pending days; removed once
   every instance is marked done. */
.dtt-series-progress {
    display: block;
    font-size: 12px;
    color: var(--dtt-text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* Steps checklist (e.g. task "wardieh" -> 3 steps to complete) */
.dtt-steps-wrap {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--dtt-bg-subtle, rgba(0,0,0,0.03));
    border-radius: 6px;
}

.dtt-steps-progress {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dtt-text-muted);
    margin-bottom: 4px;
}

.dtt-steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dtt-step-item {
    padding: 2px 0;
}

.dtt-step-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.dtt-step-name {
    line-height: 1.4;
}

.dtt-step-item.dtt-step--done .dtt-step-name {
    text-decoration: line-through;
    color: var(--dtt-text-muted);
}

/* Sequential completion: future tasks locked until today's backlog clears */
.dtt-task-item.dtt-task--locked {
    opacity: 0.65;
}

.dtt-task-item.dtt-task--locked .dtt-task-name {
    color: var(--dtt-text-muted);
}

.dtt-badge-locked {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Backlog explainer banner (sequential completion) */
.dtt-backlog-banner {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.dtt-backlog-banner-title {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
}

.dtt-backlog-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: #92400e;
}

.dtt-backlog-list li {
    padding: 2px 0;
}

.dtt-backlog-date {
    font-weight: 600;
}

/* Day navigation strip (Prev Day / Today / Next Day) on the main task view */
.dtt-day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.dtt-day-nav-btn {
    font-size: 13px;
    font-weight: 600;
    color: var(--dtt-primary, #4f46e5);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--dtt-border, #e5e7eb);
    border-radius: 6px;
    white-space: nowrap;
}

.dtt-day-nav-btn:hover {
    background: var(--dtt-bg-subtle, rgba(79,70,229,0.08));
}

.dtt-day-nav-today {
    font-size: 12px;
    color: var(--dtt-text-muted);
    text-decoration: underline;
    white-space: nowrap;
}

/* Spinner (WordPress core dashicon style) */
.dtt-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: transparent url(../img/spinner.gif) no-repeat center;
    background-size: 16px;
    visibility: hidden;
    margin-top: 2px;
}

.dtt-spinner.is-active {
    visibility: visible;
}

/* Empty state */
.dtt-empty-state {
    padding: 32px 0;
    text-align: center;
    color: var(--dtt-text-muted);
    font-size: 15px;
}

/* --------------------------------------------------------------------------
   Frontend – Quick-add form
   -------------------------------------------------------------------------- */
.dtt-quick-add-form {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.dtt-quick-add-form input[type="text"],
.dtt-quick-add-form input[type="date"],
.dtt-quick-add-form select {
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    padding: 8px 12px;
    font-size: 14px;
    color: var(--dtt-text);
    transition: var(--dtt-transition);
}

.dtt-quick-add-form input[type="text"] {
    flex: 1 1 200px;
}

.dtt-quick-add-form button[type="submit"] {
    background: var(--dtt-primary);
    color: #fff;
    border: none;
    border-radius: var(--dtt-radius);
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dtt-transition);
}

.dtt-quick-add-form button[type="submit"]:hover {
    background: var(--dtt-primary-hover);
}

.dtt-quick-add-form button[type="submit"]:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Frontend / Admin – Calendar grid (shortcode [dtt_calendar])
   -------------------------------------------------------------------------- */
.dtt-calendar-wrap {
    width: 100%;
    overflow-x: auto;
}

.dtt-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid var(--dtt-border);
    border-left: 1px solid var(--dtt-border);
}

.dtt-cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 0;
}

.dtt-cal-header-day {
    padding: 6px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--dtt-text-muted);
    background: var(--dtt-surface-2);
    border-right: 1px solid var(--dtt-border);
    border-bottom: 1px solid var(--dtt-border);
}

.dtt-cal-day {
    min-height: 80px;
    padding: 6px;
    border-right: 1px solid var(--dtt-border);
    border-bottom: 1px solid var(--dtt-border);
    background: var(--dtt-surface);
    cursor: pointer;
    transition: background .15s;
    position: relative;
}

.dtt-cal-day:hover {
    background: #f0f4ff;
}

.dtt-cal-day--empty {
    background: var(--dtt-surface-2);
    cursor: default;
}

.dtt-cal-day--today {
    background: #eef2ff;
}

.dtt-cal-day-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--dtt-text-muted);
    margin-bottom: 4px;
}

.dtt-cal-day--today .dtt-cal-day-number {
    color: var(--dtt-primary);
}

.dtt-cal-task-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dtt-warning);
    margin: 2px;
}

.dtt-cal-task-dot--done {
    background: var(--dtt-success);
}

.dtt-cal-more {
    font-size: 10px;
    color: var(--dtt-text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Popover (calendar day task list)
   -------------------------------------------------------------------------- */
.dtt-popover {
    position: absolute;
    z-index: 99999;
    background: var(--dtt-surface);
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    box-shadow: var(--dtt-shadow-lg);
    padding: 16px;
    min-width: 260px;
    max-width: 360px;
    max-height: 400px;
    overflow-y: auto;
}

.dtt-popover h4 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dtt-text);
    padding-right: 24px;
}

.dtt-popover p {
    font-size: 13px;
    color: var(--dtt-text-muted);
    margin: 4px 0;
}

.dtt-popover-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--dtt-text-muted);
    padding: 0 4px;
    transition: color .15s;
}

.dtt-popover-close:hover {
    color: var(--dtt-danger);
}

/* --------------------------------------------------------------------------
   FullCalendar admin overrides
   -------------------------------------------------------------------------- */
#dtt-fullcalendar {
    background: var(--dtt-surface);
    border: 1px solid var(--dtt-border);
    border-radius: var(--dtt-radius);
    padding: 16px;
    box-shadow: var(--dtt-shadow);
}

#dtt-fullcalendar .fc-toolbar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dtt-text);
}

#dtt-fullcalendar .fc-button-primary {
    background-color: var(--dtt-primary) !important;
    border-color: var(--dtt-primary) !important;
}

#dtt-fullcalendar .fc-button-primary:hover {
    background-color: var(--dtt-primary-hover) !important;
}

#dtt-fullcalendar .fc-event {
    border-radius: 4px;
    font-size: 12px;
    padding: 2px 4px;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media ( max-width: 600px ) {
    .dtt-stats-grid {
        grid-template-columns: 1fr;
    }

    .dtt-quick-add-form {
        flex-direction: column;
    }

    .dtt-quick-add-form input[type="text"] {
        width: 100%;
    }

    .dtt-cal-day {
        min-height: 50px;
        padding: 3px;
    }

    .dtt-cal-day-number {
        font-size: 10px;
    }

    .dtt-task-items {
        gap: 6px;
    }
}
