/* Mobile-first CSS for David's To Do List */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --urgent-color: #dc2626;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Navigation */
.nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.nav-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.nav-btn.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

/* Main Content */
.main {
    min-height: calc(100vh - 200px);
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.task-tabs {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.sub-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.sub-tab.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

/* Items List */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Item Card */
.item-card {
    background: var(--bg-primary);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.item-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.item-card.purchased {
    opacity: 0.7;
    background-color: var(--bg-tertiary);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.item-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    flex: 1;
    margin-right: 1rem;
}

.check-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-right: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.check-btn:hover {
    background-color: var(--success-color);
    color: white;
}

.item-card.purchased .check-btn {
    background-color: var(--success-color);
    color: white;
}

.quantity {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.category-badge, .amount-badge, .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.category-badge {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.amount-badge {
    background-color: #dbeafe;
    color: #1e40af;
}

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

.status-badge.processed {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-badge.completed {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.shipped {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-badge.in_transit {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.delivered {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.returned {
    background-color: #fee2e2;
    color: #991b1b;
}

.item-notes, .item-store, .item-order, .item-description, .item-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.item-photo {
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    overflow: hidden;
    max-width: 100%;
}

.item-photo img {
    width: 100%;
    height: auto;
    display: block;
}

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

/* Tasks Section */
.tasks-section {
    display: none;
}

.tasks-section.active {
    display: block;
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Task Card */
.task-card {
    background: var(--bg-primary);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.task-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    flex: 1;
    margin-right: 1rem;
}

.task-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.task-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.task-status.low {
    background-color: #f3f4f6;
    color: var(--text-secondary);
}

.task-status.normal {
    background-color: #dbeafe;
    color: #1e40af;
}

.task-status.high {
    background-color: #fef3c7;
    color: #92400e;
}

.task-status.urgent {
    background-color: #fef2f2;
    color: var(--urgent-color);
}

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

.task-photo {
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    overflow: hidden;
    max-width: 100%;
}

.task-photo img {
    width: 100%;
    height: auto;
    display: block;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 0.75rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Form */
.task-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.photo-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.photo-input-group input[type="file"] {
    flex: 1;
}

.camera-btn {
    white-space: nowrap;
    min-width: auto;
    font-size: 0.875rem;
}

.photo-preview {
    margin-top: 0.5rem;
    display: none;
}

.photo-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.task-due-date {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.task-due-date.overdue {
    background-color: #fef2f2;
    color: var(--danger-color);
}

.task-due-date.due-today {
    background-color: #fef3c7;
    color: #92400e;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (min-width: 640px) {
    .container {
        padding: 0 2rem;
    }

    .header {
        padding: 2rem 0;
    }

    .header h1 {
        font-size: 2.25rem;
    }

    .header-buttons {
        gap: 0.75rem;
    }

    .nav {
        gap: 1rem;
        padding: 0.5rem;
    }

    .nav-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .task-card, .item-card {
        padding: 1.5rem;
    }

    .task-actions, .item-actions {
        gap: 0.75rem;
    }

    .modal-content {
        width: 100%;
        max-width: 600px;
    }

    .task-form {
        padding: 2rem;
    }

    .form-actions {
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    .header-buttons {
        flex-wrap: wrap;
    }

    .header-buttons .btn {
        flex: 1;
        min-width: 120px;
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .item-actions {
        flex-direction: column;
    }

    .item-actions .btn {
        width: 100%;
    }

    .task-tabs {
        flex-wrap: wrap;
    }

    .task-tabs .sub-tab {
        flex: 1;
        text-align: center;
    }
}

@media (min-width: 768px) {
    .task-header {
        align-items: center;
    }

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

    .task-meta {
        flex-direction: row;
        align-items: center;
    }

    .task-actions {
        margin-top: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --bg-primary: #1f2937;
        --bg-secondary: #111827;
        --bg-tertiary: #374151;
        --border-color: #4b5563;
    }
}

/* Print styles */
@media print {
    .nav,
    .task-actions,
    .btn {
        display: none !important;
    }

    .task-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}