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

:root {
    --bg-color: #f5f5f5;
    --card-bg: white;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border-color: #e5e7eb;
    --task-bg: #fafafa;
    --input-border: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --card-bg: #2a2a2a;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-light: #9ca3af;
        --border-color: #404040;
        --task-bg: #1f1f1f;
        --input-border: #4b5563;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    flex-shrink: 0;
}

header h1 {
    display: block;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
    text-decoration: line-through;
}

/* User Info */
.user-info {
    display: none;
}

/* Settings Button */
.settings-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    color: var(--text-primary);
    flex-shrink: 0;
}

.settings-btn:hover {
    background: var(--task-bg);
    transform: rotate(45deg);
}

.settings-btn:active {
    transform: rotate(45deg) scale(0.95);
}

.offline-indicator {
    background: rgba(255, 152, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 8px;
    display: inline-block;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    display: block;
}

.login-container h1 {
    color: var(--text-primary);
    font-size: 2rem;
    margin-bottom: 10px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 30px;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-btn:active {
    transform: scale(0.98);
}

.google-btn {
    border-color: #4285F4;
}

.google-btn:active {
    background: #f0f4ff;
}

.apple-btn {
    border-color: #000000;
}

.guest-btn {
    border-color: #9ca3af;
}

.guest-btn:active {
    background: #f9fafb;
}

.apple-btn:active {
    background: #f9fafb;
}

.login-info {
    color: #9ca3af;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Drag & Drop Hint */
.drag-hint {
    background: var(--text-primary);
    color: var(--card-bg);
    padding: 15px 20px;
    margin: 0 10px 10px 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    animation: slideDown 0.4s ease-out;
}

.drag-hint p {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.close-hint-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.close-hint-btn:hover {
    background: var(--task-bg);
}

.close-hint-btn:active {
    transform: scale(0.95);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Add Task Section */
.add-task-section {
    display: none; /* Hidden in v1.4.5 */
}

#taskInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: transparent;
    color: var(--text-primary);
}

#taskInput:focus {
    outline: none;
    border-color: var(--text-secondary);
}

#addTaskBtn {
    padding: 8px 12px;
    background: var(--text-primary);
    color: var(--card-bg);
    border: none;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 35px;
    flex-shrink: 0;
}

#addTaskBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#addTaskBtn:active {
    transform: scale(0.95);
}

/* Segments Container - Mobile First */
.segments {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    gap: 10px;
    padding: 0 10px 10px 10px;
    padding-bottom: 80px;
    transition: transform 0.3s, opacity 0.3s;
}

.segment {
    background: transparent;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    height: auto;
}

.segment-header {
    margin-bottom: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.q1 .segment-header { border-color: #1f2937; }
.q2 .segment-header { border-color: #4b5563; }
.q3 .segment-header { border-color: #6b7280; }
.q4 .segment-header { border-color: #9ca3af; }
.q5 .segment-header { border-color: #d1d5db; }

.segment-header h2 {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 700;
    flex: 1;
}

.segment-add-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--text-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.segment-add-btn:hover {
    background: var(--text-secondary);
    color: var(--card-bg);
    transform: scale(1.1);
}

.segment-add-btn:active {
    transform: scale(0.95);
}

/* Task List */
.task-list {
    overflow-y: visible;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
    align-items: flex-start;
    min-height: 60px; /* Ensure drop target is large enough even when empty */
    transition: background 0.2s ease;
}

/* Custom Scrollbar */
.task-list::-webkit-scrollbar {
    width: 6px;
}

.task-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.task-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.task-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.task-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    flex-shrink: 0;
    position: relative;
    touch-action: pan-y;
    cursor: grab;
}

.task-item:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.1);
}

.task-item.dragging {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.15);
}

/* Delete button */
.task-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}

.task-item:hover .task-delete-btn {
    opacity: 1;
    color: #ff4444;
}

.task-delete-btn:active {
    transform: scale(1.2);
}

/* Hide add button for Done segment */
.q5 .segment-add-btn {
    display: none;
}

/* Drag over feedback */
.task-list.drag-over {
    background: rgba(102, 126, 234, 0.25);
    border: 2px dashed rgba(102, 126, 234, 0.6);
    border-radius: 8px;
    min-height: 80px;
}

/* Checkbox */
.task-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--checkbox-color, #6b7280);
    border-radius: 4px;
    background: transparent;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* Unchecked state - colored border */
.task-checkbox:not(:checked) {
    border-color: var(--checkbox-color, #6b7280);
}

/* Checked state - filled with color and checkmark */
.task-checkbox:checked {
    background-color: var(--checkbox-color, #6b7280);
    border-color: var(--checkbox-color, #6b7280);
}

.task-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.task-text {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.3;
    word-wrap: break-word;
}

.task-timestamp {
    color: var(--text-secondary);
    font-size: 0.7rem;
    opacity: 0.8;
    font-style: italic;
}


/* Done segment - checked items */
.q5 .task-item {
    opacity: 0.7;
}

.q5 .task-text {
    text-decoration: line-through;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.segment-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.segment-btn {
    padding: 20px;
    border: 2px solid;
    border-radius: 8px;
    background: var(--card-bg);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1.1rem;
    font-weight: 700;
}

.q1-btn { border-color: #ef4444; color: #ef4444; }
.q2-btn { border-color: #10b981; color: #10b981; }
.q3-btn { border-color: #f59e0b; color: #f59e0b; }
.q4-btn { border-color: #6b7280; color: #6b7280; }

.segment-btn:active {
    transform: scale(0.95);
}

.q1-btn:active { background: #fef2f2; }
.q2-btn:active { background: #f0fdf4; }
.q3-btn:active { background: #fffbeb; }
.q4-btn:active { background: #f9fafb; }

.cancel-btn {
    width: 100%;
    padding: 12px;
    background: #e5e7eb;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    transition: background 0.2s;
}

.cancel-btn:active {
    background: #d1d5db;
}

/* Recurring Task Configuration */
.recurring-config {
    margin: 20px 0;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.recurring-enable {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.recurring-enable input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.recurring-options {
    margin-top: 15px;
    padding: 10px;
    background: var(--task-bg);
    border-radius: 8px;
}

.recurring-options label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.recurring-options select,
.recurring-options input[type="number"] {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.interval-options {
    margin-top: 10px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 6px;
}

.weekday-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.weekday-selector label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--task-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.weekday-selector label:hover {
    background: var(--border-color);
}

.weekday-selector input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.recurring-indicator {
    display: inline-block;
    margin-left: 5px;
    opacity: 0.7;
    font-size: 0.9em;
}

/* Empty State */
.task-list:empty::before {
    content: "";
    color: #9ca3af;
    font-style: italic;
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
}

/* Desktop View */
@media (min-width: 769px) {
    body {
        padding: 20px;
    }

    .container {
        max-width: 1200px;
    }

    header h1 {
        font-size: 2.2rem;
        margin-bottom: 10px;
    }

    .add-task-section {
        margin: 0 0 15px 0;
        padding: 15px;
    }

    .segments {
        padding: 0;
        gap: 8px;
    }

    .segment {
        height: auto;
        padding: 15px;
    }

    .segment-header h2 {
        font-size: 1.3rem;
    }

    .task-text {
        font-size: 1rem;
    }

    .segment-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .q1-btn:hover { background: #fef2f2; }
    .q2-btn:hover { background: #f0fdf4; }
    .q3-btn:hover { background: #fffbeb; }
    .q4-btn:hover { background: #f9fafb; }

    .cancel-btn:hover {
        background: #d1d5db;
    }
}

/* Two-column layout for tasks on large screens */
@media (min-width: 1024px) {
    .task-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* Footer Styles */
footer {
    background: rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

footer a:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Settings Modal Options */
.settings-option {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-option:last-of-type {
    border-bottom: none;
}

.settings-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Language Select */
.language-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--task-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.language-select:focus {
    outline: none;
    border-color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch:checked {
    background: var(--text-primary);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch:checked::before {
    transform: translateX(24px);
}

/* Settings Action Buttons */
.settings-action-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--task-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-action-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.settings-action-btn:active {
    transform: translateY(0);
}

/* Logout Button in Settings Modal */
.logout-btn-modal {
    width: 100%;
    padding: 12px 20px;
    background: var(--text-primary);
    color: var(--card-bg);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn-modal:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.logout-btn-modal:active {
    transform: scale(0.98);
}

/* Dark Mode */
body.dark-mode {
    --bg-color: #1a1a1a;
    --card-bg: #2a2a2a;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-light: #9ca3af;
    --border-color: #404040;
    --task-bg: #1f1f1f;
    --input-border: #4b5563;
}

/* Search Highlight */
.search-highlight {
    background: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
}

body.dark-mode .search-highlight {
    background: #ffc107;
}

/* Metrics Modal */
.metrics-modal {
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
}

.metrics-container {
    margin: 15px 0;
}

.metrics-section {
    margin-bottom: 20px;
}

.metrics-section h4 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.metric-card {
    background: var(--task-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 10px;
    text-align: center;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    justify-content: center;
}

.chart-period-btn {
    padding: 6px 12px;
    background: var(--task-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-period-btn:hover {
    background: var(--border-color);
}

.chart-period-btn.active {
    background: var(--text-primary);
    color: var(--card-bg);
    border-color: var(--text-primary);
}

.metrics-section canvas {
    max-height: 250px;
    background: var(--task-bg);
    border-radius: 8px;
    padding: 10px;
}

/* ============================================================================
   Footer Styles (v1.4.5+)
   ============================================================================ */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.coffee-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #FFDD00;
    color: #000;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.2s;
}

.coffee-btn:hover {
    transform: translateY(-2px);
}

.settings-btn-footer {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
}

.settings-btn-footer:hover {
    background: var(--task-bg);
    transform: scale(1.05);
}

.settings-btn-footer:active {
    transform: scale(0.95);
}

/* ============================================================================
   Quick Add Modal Styles (v1.4.5+)
   ============================================================================ */
.quick-add-modal {
    max-width: 500px;
}

.quick-add-category {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: -5px 0 15px 0;
    font-weight: 500;
}

.quick-add-input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.quick-add-input-wrapper input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--task-bg);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.quick-add-input-wrapper input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.char-counter {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.error {
    color: #ef4444;
}

.recurring-config-quick {
    background: var(--task-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.recurring-enable {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.recurring-enable input[type="checkbox"] {
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.submit-btn {
    background: var(--text-primary);
    color: var(--card-bg);
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   Hidden Element Utility
   ============================================================================ */
.hidden {
    display: none !important;
}

/* ============================================================================
   Mobile Optimizations for v1.4.5
   ============================================================================ */
@media (max-width: 600px) {
    .app-footer {
        justify-content: center;
    }

    .quick-add-modal {
        max-width: 95%;
        margin: 20px;
    }

    .modal-buttons {
        flex-direction: column-reverse;
    }

    .modal-buttons button {
        width: 100%;
    }
}

/* ============================================================================
   Drag & Drop 2.0 Styles (Phase 2)
   ============================================================================ */

/* Prevent text selection during drag */
.task-item {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Prevent pull-to-refresh interfering with drag */
body {
    overscroll-behavior-y: contain;
}

/* Drop zone highlighting */
.task-list.drag-over {
    border: 2px dashed var(--segment-color, #667eea);
    background: linear-gradient(
        to bottom,
        rgba(var(--segment-color-rgb, 102, 126, 234), 0.05),
        rgba(var(--segment-color-rgb, 102, 126, 234), 0.1)
    );
    transform: scale(1.02);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Invalid drop zone (if needed in future) */
.task-list.drag-invalid {
    border: 2px dashed #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

/* Task being dragged (original element) */
.task-item.dragging {
    opacity: 0.3 !important;
    transform: scale(0.98);
    transition: all 0.2s ease;
}

/* Task moved successfully animation */
@keyframes task-moved {
    0% {
        background: var(--segment-color);
        transform: scale(1.05);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

.task-item.just-moved {
    animation: task-moved 0.6s ease;
}

/* Clone element styles (applied via JS) */
/* These are set in drag-manager.js but documented here for reference:
   - position: fixed
   - z-index: 9999
   - pointer-events: none
   - transform: scale(1.05) rotate(2deg)
   - opacity: 0.9
   - box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3)
*/

/* Swipe to delete visual feedback */
.task-item.swiping-left {
    transition: transform 0.1s ease, opacity 0.1s ease;
}

/* Cursor styles for desktop drag */
.task-item[draggable="true"] {
    cursor: grab;
}

.task-item[draggable="true"]:active {
    cursor: grabbing;
}

.task-list.drag-over {
    cursor: move;
}

.task-list.drag-invalid {
    cursor: not-allowed;
}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
    /* Mobile/Touch devices */
    .task-item {
        -webkit-tap-highlight-color: transparent;
    }

    /* Ensure smooth touch dragging */
    .task-item {
        touch-action: manipulation;
    }
}

/* Hardware acceleration for smooth animations */
.task-item,
.task-list {
    transform: translateZ(0);
    will-change: transform, opacity;
}

/* Segment-specific drop zone colors */
.task-list[data-segment="1"].drag-over {
    --segment-color: #e74c3c;
    --segment-color-rgb: 231, 76, 60;
}

.task-list[data-segment="2"].drag-over {
    --segment-color: #f39c12;
    --segment-color-rgb: 243, 156, 18;
}

.task-list[data-segment="3"].drag-over {
    --segment-color: #3498db;
    --segment-color-rgb: 52, 152, 219;
}

.task-list[data-segment="4"].drag-over {
    --segment-color: #95a5a6;
    --segment-color-rgb: 149, 165, 166;
}

.task-list[data-segment="5"].drag-over {
    --segment-color: #27ae60;
    --segment-color-rgb: 39, 174, 96;
}

/* Animation for drag start (long press visual feedback) */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.task-item.long-press-active {
    animation: pulse 0.3s ease-out;
}

/* Offline sync indicator on dragged items */
.task-item[data-sync-status="pending"]::after {
    content: "⏳";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
    opacity: 0.6;
}

.task-item[data-sync-status="failed"]::after {
    content: "⚠️";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
}

/* Accessibility: Focus indicators for keyboard navigation */
.task-item:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.task-list:focus-visible {
    outline: 2px dashed #667eea;
    outline-offset: 4px;
}

/* ============================================
   Accessibility: Keyboard Navigation Styles
   ============================================ */

/* Task item selected for keyboard move */
.task-item.keyboard-selected {
    outline: 3px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
    background: rgba(0, 123, 255, 0.05);
    position: relative;
}

.task-item.keyboard-selected::before {
    content: "✓ Selected";
    position: absolute;
    top: -24px;
    left: 0;
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    z-index: 100;
}

/* Target quadrant highlight */
.segment.keyboard-target {
    outline: 3px dashed #28a745;
    outline-offset: -3px;
    background: rgba(40, 167, 69, 0.05);
    position: relative;
}

.segment.keyboard-target::before {
    content: "→ Target (Press Enter to move)";
    position: absolute;
    top: 8px;
    right: 8px;
    background: #28a745;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Enhanced focus indicators for keyboard navigation */
*:focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
    border-radius: 4px;
}

.task-item:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

/* Dark mode adjustments for keyboard selection */
@media (prefers-color-scheme: dark) {
    .task-item.keyboard-selected {
        background: rgba(0, 123, 255, 0.1);
        outline-color: #4dabf7;
    }

    .task-item.keyboard-selected::before {
        background: #4dabf7;
    }

    .segment.keyboard-target {
        background: rgba(40, 167, 69, 0.1);
        outline-color: #51cf66;
    }

    .segment.keyboard-target::before {
        background: #51cf66;
        color: #1a1a1a;
    }
}

body.dark-mode .task-item.keyboard-selected {
    background: rgba(0, 123, 255, 0.1);
    outline-color: #4dabf7;
}

body.dark-mode .task-item.keyboard-selected::before {
    background: #4dabf7;
}

body.dark-mode .segment.keyboard-target {
    background: rgba(40, 167, 69, 0.1);
    outline-color: #51cf66;
}

body.dark-mode .segment.keyboard-target::before {
    background: #51cf66;
    color: #1a1a1a;
}
