/* ===================================
   Pro Task Manager — Web App Styles
   Mobile-first, modern dashboard
   =================================== */

/* ----- CSS Variables (Light Theme) ----- */
:root {
    --bg-primary: #F4F6FB;
    --bg-card: #FFFFFF;
    --bg-input: #F8F9FC;
    --bg-hover: #EEF0F6;
    --bg-overlay: rgba(0,0,0,0.45);
    --text-primary: #1E1E2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --accent: #6366F1;
    --accent-light: #818CF8;
    --accent-bg: rgba(99,102,241,0.08);
    --danger: #EF4444;
    --danger-bg: rgba(239,68,68,0.08);
    --success: #10B981;
    --success-bg: rgba(16,185,129,0.08);
    --warning: #F59E0B;
    --border: #E5E7EB;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
}

/* ----- Dark Theme ----- */
body.dark {
    --bg-primary: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-input: #22223A;
    --bg-hover: #2A2A42;
    --bg-overlay: rgba(0,0,0,0.65);
    --text-primary: #E8E8F0;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --accent: #818CF8;
    --accent-light: #A5B4FC;
    --accent-bg: rgba(129,140,248,0.12);
    --danger: #F87171;
    --danger-bg: rgba(248,113,113,0.12);
    --success: #34D399;
    --success-bg: rgba(52,211,153,0.12);
    --border: #2D2D44;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

/* ----- Splash Screen ----- */
.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
}

.splash-content {
    text-align: center;
    color: #fff;
}

.splash-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
}

.splash-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* Spinner animation */
.splash-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----- Login Screen ----- */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 24px;
}

.login-card {
    text-align: center;
    max-width: 380px;
    width: 100%;
    padding: 48px 32px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: #fff;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Google sign-in button */
.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.google-btn:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.google-btn:active {
    transform: scale(0.97);
}

/* ----- App Container ----- */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px 100px;
    position: relative;
}

/* ----- Header ----- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.icon-btn:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

/* Sync status dot */
.sync-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}
.sync-status.syncing {
    animation: pulse 1s infinite;
    background: var(--warning);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ----- Settings Panel ----- */
.settings-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    padding: 20px;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* User info */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* Setting row */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-primary);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Select dropdown */
.setting-select {
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}
.setting-select:focus {
    border-color: var(--accent);
}

/* Range group */
.range-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.range-group input[type="range"] {
    width: 100px;
    accent-color: var(--accent);
}
.range-group span {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 20px;
    text-align: center;
}

/* Sign out button */
.signout-btn {
    width: 100%;
    padding: 10px;
    background: var(--danger-bg);
    color: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 4px;
}
.signout-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* ----- Tabs ----- */
.tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 4px;
    margin-bottom: 16px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* ----- FAB (Floating Action Button) ----- */
.fab {
    position: fixed;
    bottom: 28px;
    right: max(calc((100vw - 600px)/2 + 28px), 28px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: #fff;
    font-size: 28px;
    border: none;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    cursor: pointer;
    z-index: 50;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(99,102,241,0.5);
}
.fab:active {
    transform: scale(0.95);
}

/* ----- Input Card (Add Task / Add Note) ----- */
.input-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 16px;
    margin-bottom: 16px;
    animation: slideDown 0.25s ease-out;
}

.input-card input[type="text"],
.input-card textarea,
.input-card input[type="date"],
.input-card input[type="time"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 10px;
    outline: none;
    transition: border-color var(--transition);
}
.input-card input:focus,
.input-card textarea:focus,
.input-card select:focus {
    border-color: var(--accent);
}

.input-card textarea {
    resize: vertical;
    min-height: 60px;
}

.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.input-row input,
.input-row select {
    flex: 1;
    min-width: 0;
}
.input-row input[type="date"],
.input-row input[type="time"] {
    margin-bottom: 0;
}

.priority-select {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Buttons */
.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary:hover {
    background: var(--accent-light);
}
.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    padding: 10px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    padding: 10px 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover {
    opacity: 0.9;
}

/* ----- Item List (Tasks / Notes / History) ----- */
.item-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Individual task / note card */
.task-card,
.note-card,
.history-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    border-left: 3px solid transparent;
}
.task-card:hover,
.note-card:hover,
.history-card:hover {
    box-shadow: var(--shadow-md);
}

/* Priority borders for tasks */
.task-card.priority-low { border-left-color: #3B82F6; }
.task-card.priority-medium { border-left-color: #F59E0B; }
.task-card.priority-high { border-left-color: #EF4444; }

/* Task completed state */
.task-card.completed {
    opacity: 0.55;
}
.task-card.completed .task-title {
    text-decoration: line-through;
}

/* Task layout */
.task-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.task-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition: all var(--transition);
    background: transparent;
}
.task-checkbox:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}
.task-checkbox.checked {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
    font-size: 12px;
}

.task-body {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.task-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.4;
}

/* .task-desc replaced by .task-desc-content (show-desc toggle section) */

.task-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.task-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-date.overdue {
    color: var(--danger);
    font-weight: 600;
}

/* Task action buttons */
.task-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 16px;
}
.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.action-btn.delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ----- Note Card ----- */
.note-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.4;
}

/* .note-text replaced by .note-text-content (show-desc toggle section) */

.note-body {
    flex: 1;
    min-width: 0;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

/* ----- History Card ----- */
.history-card {
    border-left-color: var(--text-muted);
    opacity: 0.7;
}
.history-card .task-title {
    text-decoration: line-through;
}
/* Priority borders in history */
.history-card.priority-low { border-left-color: #3B82F6; }
.history-card.priority-medium { border-left-color: #F59E0B; }
.history-card.priority-high { border-left-color: #EF4444; }
.history-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ----- Confirm Overlay ----- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
}

.confirm-message {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ----- Click-to-Expand Description (show-desc toggle) ----- */
/* Task description — hidden by default, shown on click */
.task-desc-content {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
}
.task-card.show-desc .task-desc-content,
.history-card.show-desc .task-desc-content {
    display: block;
}
/* Note text — hidden by default, shown on click */
.note-text-content {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
}
.note-card.show-desc .note-text-content,
.history-card.show-desc .note-text-content {
    display: block;
}
/* Clickable areas get pointer cursor via their original rules above */

/* ----- History Section Labels ----- */
.history-section-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 4px 4px;
    list-style: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
/* History note cards — no line-through on title */
.history-card.note-history .task-title {
    text-decoration: none;
    font-style: italic;
}

/* ----- Edit Mode (Inline) ----- */
.edit-mode-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.edit-input,
.edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.edit-textarea {
    resize: vertical;
    min-height: 60px;
}
.edit-priority {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    cursor: pointer;
}
.edit-mode-container .input-row {
    display: flex;
    gap: 8px;
}
.edit-mode-container .input-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}
.edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 4px;
}
/* Task card in editing state — extra padding */
.task-card.editing,
.note-card.editing {
    padding: 16px;
}

/* ----- Empty State ----- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-state-text {
    font-size: 15px;
    font-weight: 500;
}

/* ----- Drag & Drop ----- */
.task-card.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}
.task-card.drag-over {
    border-top: 2px solid var(--accent);
}
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0 4px;
    user-select: none;
}
.drag-handle:active {
    cursor: grabbing;
}

/* ----- Toast Notification ----- */
.toast {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ----- Responsive — larger screens ----- */
@media (min-width: 640px) {
    .app-container {
        padding: 0 24px 100px;
    }
    .header {
        padding: 20px 0;
    }
    .task-card,
    .note-card,
    .history-card {
        padding: 16px 20px;
    }
}

/* ----- PWA safe area (notch devices) ----- */
@supports (padding: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    .fab {
        bottom: calc(28px + env(safe-area-inset-bottom));
    }
}
