/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Allow text selection for input fields and textareas */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Prevent zoom on input focus on iOS */
input[type="text"], input[type="email"], input[type="password"], textarea {
    font-size: 16px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Prevent pull-to-refresh */
    body {
        overscroll-behavior: none;
    }
    
    /* Ensure proper touch targets */
    button, .task-item, .task-checkbox {
        min-height: 44px;
        min-width: 44px;
    }

    .app-mode-title-bar {
      padding-top: env(safe-area-inset-top) !important;
    }
}

.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
}

/* Header */
.header {
    margin-bottom: 3rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-text {
    text-align: left;
}

.app-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.sign-in-btn, .sign-out-btn {
    background: #24292e;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sign-in-btn:hover {
    background: #1a1e22;
}

.sign-out-btn {
    background: #e74c3c;
}

.sign-out-btn:hover {
    background: #c0392b;
}

.github-icon {
    width: 16px;
    height: 16px;
}

/* Content Split Layout */
.content-split {
    display: flex;
    align-items: stretch;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 600px;
    max-height: 800px;
}

.task-list-container {
    flex: 1;
    min-width: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}

.task-detail-panel {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    width: 400px;
    display: none;
    flex-shrink: 0;
    border-left: 1px solid #f0f0f0;
    flex-direction: column;
    position: relative;
}

.task-detail-panel.active {
    display: flex;
}

/* Responsive task list width when detail panel is open */
@media (min-width: 769px) {
    .content-split.detail-open .task-list-container {
        flex: 0 0 400px;
        max-width: 400px;
    }
}

.task-detail-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.close-detail-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.3rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
    z-index: 10;
}

.close-detail-btn:hover {
    background: #f0f0f0;
}

.task-detail-body {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.task-list {
    flex: 1;
    min-height: 200px;
    max-height: 100%;
    overflow-y: auto;
}

.task-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    line-height: 1.35rem;
}

.task-item.completed + .task-item.completed {
  border-top: none;
}

.task-item.completed {
  padding: 0.2rem 1.5rem;
}

.task-item:not(.completed) + .task-item.completed {
  padding-top: 1.2rem;
}

.task-item.completed:has(+ .task-item:not(.completed)) {
  padding-bottom: 1.2rem;
}

.task-item:hover {
    background: #f8f9fa;
}

.task-item:last-child {
    border-bottom: none;
}

/* Completed tasks only show strikethrough and checkbox - no opacity change */

.task-item.selected {
    background: #f0f8ff;
    border-left: 3px solid #3498db;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: #2c3e50;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    margin-right: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.task-checkbox:hover {
    border-color: #3498db;
}

.task-checkbox.checked {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.task-checkbox.checked::after {
    content: '✓';
    font-size: 12px;
    font-weight: bold;
}

.task-checkbox-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.task-title {
    font-size: 1rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.task-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lifetime-badge {
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.lifetime-badge.fading {
    background: #fdf2e9;
    color: #e67e22;
}

.lifetime-badge.critical {
    background: #fadbd8;
    color: #e74c3c;
}

/* Fading effect for tasks */
.task-item.fade-1 { opacity: 0.8; }
.task-item.fade-2 { opacity: 0.6; }
.task-item.fade-3 { opacity: 0.3; }
.task-item.fade-4 { opacity: 0.1; }

/* Add Task */
.add-task-container {
    padding: 0;
    background: white;
    display: flex;
    gap: 1rem;
    align-items: center;
    border-top: 1px solid #EEE;
}

.new-task-input {
    flex: 1;
    padding: 1.4rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s ease;
    padding-left: 1.7rem;
}

.new-task-input:focus {
    outline: none;
    border-color: #3498db;
}

.add-task-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    margin-right: 0.6rem;
    justify-content: center;
}

.add-task-btn:hover {
    background: #2980b9;
}

.plus-icon {
    width: 18px;
    height: 18px;
}

/* Task Area Sign-in Button */
.task-area-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.4rem 1rem;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    margin: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
    font-size: 0.95rem;
    font-weight: 500;
}

.task-area-signin:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

.task-area-signin .github-icon {
    width: 18px;
    height: 18px;
}

/* App Mode Title Bar */
.app-mode-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    min-height: 48px;
    flex-shrink: 0;
}

.title-bar-left {
    display: flex;
    align-items: center;
}

.app-title-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.title-bar-right {
    display: flex;
    align-items: center;
}

.app-mode-sign-out-btn {
    background: transparent;
    color: #AAAAAA;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.app-mode-sign-out-btn:hover {
    text-decoration: underline;
}

.app-mode-exit-btn {
    background: transparent;
    color: #AAAAAA;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    margin-right: 1rem;
}

.app-mode-exit-btn:hover {
    text-decoration: underline;
}

/* Enter App Mode Link */
.app-mode-link-container {
    text-align: center;
    padding: 1rem 0;
}

.enter-app-mode-link {
    color: #AAAAAA;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.enter-app-mode-link:hover {
    color: #7f8c8d;
    text-decoration: underline;
}

/* App Mode Styles */
body.appmode .header,
body.appmode .philosophy-section,
body.appmode .footer,
body.appmode .app-mode-link-container {
    display: none;
}

/* Hide everything under .main-content except .content-split in app mode */
body.appmode .main-content > *:not(.content-split) {
    display: none;
}

/* Hide everything in .app except .main-content in app mode */
body.appmode .app > *:not(.main-content) {
    display: none;
}

body.appmode .content-split {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh; /* Dynamic viewport height for iOS */
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    z-index: 1000;
    /* Safe area padding for iOS notch/home indicator */
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

body.appmode .app {
    max-width: none;
    padding: 0;
    min-height: 100vh;
}

body.appmode {
    background: white;
    overflow: hidden; /* Prevent body scroll in app mode */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
}

html.appmode {
    overflow: hidden; /* Prevent html scroll in app mode */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
}

/* Desktop App Mode - Responsive task list width when detail panel is open */
@media (min-width: 769px) {
    body.appmode .content-split.detail-open .task-list-container {
        flex: 0 0 400px;
        max-width: 400px;
    }
    
    body.appmode .content-split.detail-open .task-detail-panel {
        flex: 1;
        width: auto;
        min-width: 0;
    }
}

/* PWA Standalone Mode Detection */
@media (display-mode: standalone) {
    body.appmode .content-split {
        height: 100dvh; /* Perfect in PWA shell */
        max-height: 100dvh;
    }
    
    /* Only apply full height to task list on desktop standalone mode */
    @media (min-width: 769px) {
        body.appmode .task-list-container {
            height: 100dvh;
            min-height: 100dvh;
            max-height: 100dvh;
        }
    }
}

/* Fallback for older browsers that don't support dvh */
@supports not (height: 100dvh) {
    body.appmode .content-split {
        height: 100vh;
        max-height: 100vh;
    }
    
    @media (display-mode: standalone) {
        body.appmode .content-split {
            height: 100vh;
            max-height: 100vh;
        }
    }
}

/* Mobile App Mode Specific Styles */
@media (max-width: 768px) {
    body.appmode .task-list-container {
        position: relative; /* For absolute positioning of add task area */
        height: 100dvh; /* Full height for task list */
        min-height: 100dvh;
        max-height: 100dvh;
        /* Account for safe area insets */
        /* padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* Make room for add task area */
        display: flex;
    }
    
    body.appmode .add-task-container {
        background: white;
        padding: 0;
        border-top: 1px solid #e0e0e0;
        z-index: 10;
        height: 80px; /* Fixed height for add task container */
        box-sizing: border-box;
    }
    
    /* Fallback for older browsers */
    @supports not (height: 100dvh) {
        body.appmode .task-list-container {
            height: 100vh;
            min-height: 100vh;
            max-height: 100vh;
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
}

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

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.close-btn:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.task-title-section {
    margin-bottom: 0;
}

.task-title-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    font-size: 1.4rem;
    font-weight: 500;
    background: transparent;
}

.task-title-input:focus {
    outline: none;
}

.task-body-section {
    margin-bottom: 2rem;
}

.task-body-textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: none;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    resize: vertical;
    background: transparent;
    cursor: text;
}

.task-body-textarea:focus {
    outline: none;
}

.task-body-preview {
    padding: 1rem;
    background: white;
    border-radius: 8px;
    min-height: 60px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-body-preview.active {
    display: block;
}

.task-body-preview:not(.active) {
    display: none;
}

.task-body-textarea {
    display: none;
}

.task-body-textarea.active {
    display: block;
}

.task-body-preview h1, .task-body-preview h2, .task-body-preview h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.task-body-preview p {
    margin-bottom: 0.75rem;
}

.task-body-preview strong {
    font-weight: 600;
}

.task-body-preview em {
    font-style: italic;
}

.task-meta-section {
    margin-top: auto;
    padding: 0;
}

.lifetime-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 0;
}

.lifetime-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lifetime-label {
    font-weight: 500;
    color: #7f8c8d;
}

.lifetime-value {
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.lifetime-value:hover {
    background-color: #d5dbdb;
}

.lifetime-input {
    width: 60px;
    padding: 0.3rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    background: white;
}

.lifetime-input:focus {
    outline: none;
    border-color: #3498db;
}

.renew-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-left: 0.5rem;
}

.renew-btn:hover {
    background: #5a6268;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
}

.save-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.save-btn:hover {
    background: #2980b9;
}

.delete-btn {
    background: transparent;
    color: #6c757d;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: underline;
}

.delete-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Drag and drop */
.task-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.task-item.drag-over {
    border-top: 3px solid #3498db;
}

/* Responsive */
@media (max-width: 768px) {
    .app {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .content-split {
        flex-direction: column;
        gap: 1rem;
    }

    body.appmode .content-split {
      padding-bottom: 0;
      padding-top: 0;
    }
    
    .task-detail-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }
    
    .task-detail-panel.active {
        display: flex;
    }
    
    .task-detail-content {
        background: white;
        border-radius: 12px;
        width: 100%;
        max-width: 500px;
        max-height: 90vh;
        overflow-y: auto;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        position: relative;
    }
    
    
    .task-detail-body {
        padding: 1.5rem;
        padding-top: 3rem; /* Make room for close button */
    }
    
    .task-meta-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .task-actions {
        justify-content: center;
    }
    
    /* Fix task list scrolling on mobile */
    .task-list-container {
        height: calc(100vh - 200px); /* Account for header and add task UI */
        min-height: 300px;
        max-height: calc(100vh - 200px);
    }
    
    .task-list {
        max-height: 100%;
        overflow-y: auto;
    }
}

/* Delete Notification */
.delete-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #2c3e50;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.undo-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.undo-btn:hover {
    background: #2980b9;
}

/* Philosophy Section */
.philosophy-section {
    padding: 2rem 0;
    margin-top: 2rem;
}

.philosophy-section .philosophy-title {
  font-weight: normal;
}

.philosophy-section .philosophy-title strong {
  font-weight: 600;
}

.philosophy-section h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

.philosophy-section p {
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
    margin-bottom: 1.2rem;
}

.philosophy-section p:last-child {
    margin-bottom: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #7f8c8d;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #95a5a6;
}

.empty-state p {
    font-size: 0.9rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid #e0e0e0;
}

.footer a {
    color: #7f8c8d;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #2c3e50;
}