/* ==============================================
   Daily Task Tracker — styles.css
   Mobile-First Responsive Design
   ============================================== */

:root {
    --bg-main: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --border-color: #334155;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-green: #10b981;
    --accent-green-hover: #059669;
    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-yellow: #f59e0b;
    --accent-yellow-hover: #d97706;

    --font-family: 'Inter', sans-serif;
    --shadow-subtle: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-glow-red: 0 0 15px rgba(239, 68, 68, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    padding-bottom: 60px;
    /* Prevent horizontal overflow on mobile */
    overflow-x: hidden;
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
}

/* ── Header ── */
.app-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
    /* Give enough padding-top so settings btn doesn't overlap h1 */
    padding-top: 2.75rem;
    position: relative;
}

.app-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
    line-height: 1.2;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Settings btn — top-right of header, below status bar */
#settings-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s, transform 0.3s;
    padding: 0.25rem;
    line-height: 1;
}
#settings-btn:hover {
    color: var(--text-primary) !important;
    transform: rotate(45deg);
}

/* ── Sync Status Indicator ── */
.sync-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.sync-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-green);
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 5px var(--accent-green);
    transition: background 0.3s;
}

.sync-status.syncing .sync-dot {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px var(--accent-yellow);
    animation: pulseDot 1s infinite alternate;
}

.sync-status.error .sync-dot {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

@keyframes pulseDot {
    from { opacity: 0.4; transform: scale(0.8); }
    to   { opacity: 1;   transform: scale(1.2); }
}

/* ── Dashboard Stats Grid ── */
.dashboard {
    display: grid;
    /* Mobile: 3 cols first row, then remaining */
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem 0.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-subtle);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.stat-card p {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

/* Highlighted stat cards take full row on mobile */
.highlighted-stat {
    grid-column: span 1;
}

.highlighted-stat.wasted-bg {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}
.highlighted-stat.wasted-bg p { color: var(--accent-red); }

.highlighted-stat.productive-bg {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}
.highlighted-stat.productive-bg p { color: var(--accent-green); }

/* ── Add Task Section ── */
.add-task-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.15rem 1rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

#task-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.input-group label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-group input,
.input-group select {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
    width: 100%;
    /* Fix mobile font-size zoom on iOS */
    -webkit-text-size-adjust: 100%;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--accent-blue);
}

/* Two-column row for short fields */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

button {
    cursor: pointer;
    font-family: var(--font-family);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--accent-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    height: 46px;
    width: 100%;
}

.primary-btn:hover { background: var(--accent-blue-hover); }

/* ── Task List ── */
.task-list-section { }

.list-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.list-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.danger-text-btn {
    background: transparent;
    color: var(--accent-red);
    font-size: 0.85rem;
}
.danger-text-btn:hover { text-decoration: underline; }

.date-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    max-width: 450px;
    margin: 0 auto;
}

.date-selector input[type="date"] {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    text-align: center;
    cursor: pointer;
    outline: none;
    font-weight: 600;
    min-width: 0;
    flex: 1;
}

.date-selector .action-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

.task-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Task Card — Mobile-First 3-Row Layout ── */
.task-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.task-card.active {
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.task-card.overtime {
    border-color: var(--accent-red);
    box-shadow: var(--shadow-glow-red);
    background: linear-gradient(90deg, var(--bg-secondary) 80%, rgba(239,68,68,0.1) 100%);
}

.task-card.completed { opacity: 0.65; }

/* ── Card Top Row: Title Block + Timer ── */
.card-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.card-title-block {
    flex: 1;
    min-width: 0; /* Allows text truncation */
}

.task-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    color: #ffffff;
    word-break: break-word;
}

/* Timer — right side of top row */
.card-timer-block {
    font-family: monospace;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    color: var(--text-primary);
    flex-shrink: 0;
    align-self: center;
}
.card-timer-block.overtime-text { color: var(--accent-red); }

.badge {
    font-size: 0.65rem;
    padding: 0.18rem 0.45rem;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.badge.pending   { background: #475569; color: white; }
.badge.active    { background: rgba(59,130,246,0.2); color: #60a5fa; }
.badge.paused    { background: rgba(245,158,11,0.2); color: #fbbf24; }
.badge.completed { background: rgba(16,185,129,0.2); color: #34d399; }

.task-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.info-toggle-btn {
    background: rgba(255,255,255,0.05);
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    transition: background 0.2s;
    flex-shrink: 0;
}
.info-toggle-btn:hover { background: rgba(255,255,255,0.15); }

.task-details-box {
    margin-top: 0.6rem;
    padding: 0.65rem 0.75rem;
    background: rgba(0,0,0,0.2);
    border-left: 2px solid var(--accent-blue);
    border-radius: 0 8px 8px 0;
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Progress Bar — full width */
.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-blue);
    width: 0%;
    border-radius: 3px;
    transition: width 1s linear, background-color 0.3s ease;
}
.progress-bar.over { background: var(--accent-red); }

/* ── Card Bottom Row: Edit link + Action Buttons ── */
.card-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 0.1rem;
}

.card-edit-link {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.card-edit-link:hover {
    background: rgba(255,255,255,0.07);
    color: var(--text-primary);
}

/* Left side: Edit + Delete icon grouped together */
.card-left-btns {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Trash delete icon button — subtle, always visible */
.card-delete-link {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: rgba(239, 68, 68, 0.6);
    font-size: 0.9rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    height: 32px;
    width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.card-delete-link:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: var(--accent-red);
    color: var(--accent-red);
    transform: scale(1.1);
}

.card-action-btns {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
}

/* New Card Buttons — Large Touch Targets */
.card-btn {
    padding: 0.65rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 44px;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.card-btn-start  { background: var(--accent-blue);   color: white; }
.card-btn-start:hover  { background: var(--accent-blue-hover); transform: translateY(-1px); }

.card-btn-pause  { background: var(--accent-yellow);  color: white; }
.card-btn-pause:hover  { background: var(--accent-yellow-hover); }

.card-btn-finish { background: var(--accent-green);   color: white; }
.card-btn-finish:hover { background: var(--accent-green-hover); transform: translateY(-1px); }

.card-btn-delete {
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}
.card-btn-delete:hover { background: rgba(239,68,68,0.1); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-subtle);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

/* ── Smart Free Slots Widget ── */
.free-slots-section {
    background: linear-gradient(135deg, rgba(30,41,59,0.8), rgba(15,23,42,0.9));
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1.25rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(59,130,246,0.06);
}

.free-slots-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.free-slots-icon { font-size: 1.1rem; }

.free-slots-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.free-slots-subtitle {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
    width: 100%;          /* Always full width — no overflow */
    margin-top: 0.1rem;
}

.free-slots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 32px;
    align-items: center;
}

.slot-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.35);
    color: #93c5fd;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    /* Allow wrapping on very small screens */
    white-space: nowrap;
}

.slot-badge:hover,
.slot-badge:active {
    background: rgba(59,130,246,0.28);
    border-color: #3b82f6;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.25);
}

.slot-badge .slot-duration {
    font-size: 0.68rem;
    color: #60a5fa;
    font-weight: 500;
    opacity: 0.85;
}

.no-slots-msg {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    bottom: 16px;
    right: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--accent-yellow);
    color: var(--text-primary);
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    font-size: 0.88rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    animation: slideUp 0.3s ease-out forwards, fadeOutToast 0.5s ease-in 4.5s forwards;
    max-width: 100%;
    pointer-events: auto;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fadeOutToast {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ── Tablet & Desktop Overrides (>= 600px) ── */
@media (min-width: 600px) {
    .app-container {
        padding: 2rem 1.5rem;
    }

    .app-header {
        padding-top: 0.5rem;
    }

    .app-header h1 {
        font-size: 2.4rem;
    }

    /* Stats: 6 cols on bigger screens */
    .dashboard {
        grid-template-columns: repeat(6, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem 1rem;
    }

    .stat-card h3 { font-size: 0.85rem; }
    .stat-card p  { font-size: 1.75rem; }

    /* Form: flex row on desktop */
    #task-form {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 1.25rem;
    }

    .input-group {
        flex: 1;
        min-width: 180px;
        width: auto;
    }

    .form-row-2 {
        display: contents; /* dissolve into flex parent */
    }

    .primary-btn {
        width: auto;
        min-width: 120px;
    }

    /* Task cards: column layout on all screen sizes — just refine sizing on desktop */
    .task-card {
        padding: 1.1rem 1.4rem;
        gap: 0.85rem;
    }

    .card-timer-block {
        font-size: 1.8rem;
    }

    .card-btn {
        padding: 0.7rem 1.6rem;
        font-size: 1rem;
    }

    .toast-container {
        left: auto;
        right: 20px;
        width: 340px;
    }

    .free-slots-subtitle {
        width: auto;
        margin-top: 0;
        margin-left: auto;
    }
}