@import url('https://fonts.googleapis.com/css2?family=Jost:wght@400;600&display=swap');

:root {
    --primary-color: #5DADE2;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --sidebar-width: 250px;
    --cream-bg: rgb(254, 252, 232);
    --light-gray-bg: rgb(243, 244, 246);
    --gray-text: rgb(156, 163, 175);
    --dark-text: rgb(39, 39, 42);
    --blue-text: #5DADE2;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

html {
    /* iOS Safari fix */
    height: -webkit-fill-available;
}

body {
    font-family: 'Jost', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    /* Use exact height, not min-height */
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    /* Safe area insets for PWA notches/status bars */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    /* Ensure padding doesn't add to height */
    box-sizing: border-box;
}

.page {
    display: flex;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Hidden checkbox for menu toggle */
.menu-toggle-checkbox {
    display: none;
}

/* Sidebar - Desktop (always visible) */
.sidebar {
    width: var(--sidebar-width);
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 1rem;
    transition: transform 0.3s ease;
    z-index: 1000;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Sidebar logo at bottom */
.sidebar-logo {
    margin-top: auto;
    padding-bottom: 1.5rem;
    text-align: center;
}

.sidebar-logo img {
    height: 96px;
    max-height: 96px;
    width: auto;
    max-width: 100%;
}

/* Sidebar overlay (only on mobile when menu is open) */
.sidebar-overlay {
    display: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Critical for flex children to shrink */
    min-width: 0; /* Critical for text-overflow in flex children */
}

.top-row {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 0.15rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 0;
    height: 28px;
    flex-wrap: nowrap;
    font-size: 13px;
}

.top-row-content {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
}

.top-row-content .greeting {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    text-align: right;
    font-size: 13px;
}

/* Menu toggle button - hidden on desktop */
.menu-toggle-button {
    display: none;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    line-height: 1;
    transition: background-color 0.2s;
}

.menu-toggle-button:hover {
    background-color: #e9ecef;
}

/* Sidebar close button - hidden on desktop, top-right on mobile */
.sidebar-close-button {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
    color: #333;
    line-height: 1;
    transition: background-color 0.2s;
    z-index: 10;
}

.sidebar-close-button:hover {
    background-color: #e9ecef;
}

/* Show/hide menu icons based on checkbox state */
.menu-toggle-checkbox:not(:checked) ~ main .menu-icon-close {
    display: none;
}

.menu-toggle-checkbox:checked ~ main .menu-icon-open {
    display: none;
}

.content {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Critical for flex children to shrink */
    min-width: 0; /* Critical for text-overflow in flex children */
}

/* Top input bar - container without background */
.task-input-bar {
    background-color: transparent;
    padding: 0 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 28px;
    height: 28px;
    order: -1; /* Top on desktop */
}

.task-input-bar input {
    border: none;
    background-color: var(--cream-bg);
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Jost', sans-serif;
    outline: none;
    color: var(--dark-text);
    height: 24px;
    line-height: 24px;
    /* Position: align text with task item label */
    margin-left: 0;
    padding: 0 8px 0 42px;
    /* Width: reasonable input field width, not spanning full row */
    flex: 1 1 auto;
    max-width: 450px;
}

.task-input-bar input::placeholder {
    color: var(--gray-text);
    font-weight: 400;
}

.late-indicator {
    color: var(--gray-text);
    font-size: 14px;
    padding: 0 0.5rem;
    white-space: nowrap;
}

/* Compact task list - matches original exactly: 25px per item */
.task-list-compact {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    order: 0;
    min-height: 0; /* Critical for flex children to shrink */
}

.task-list-compact ul {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow: hidden;
}

/* Exact match to original: 25px height, 0 padding */
.task-item-compact {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    gap: 0.5rem;
    height: 25px;
    line-height: 24px;
    min-width: 0;
    overflow: hidden;
}

.task-item-compact:hover {
    background-color: #f9fafb;
}

.task-item-compact input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.due-date-dot {
    font-size: 12px;
    line-height: 24px;
    flex-shrink: 0;
}

.task-item-compact label {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-text);
    cursor: pointer;
    margin: 0;
    line-height: 24px;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.task-item-compact.completed label {
    text-decoration: line-through;
    color: var(--gray-text);
    font-weight: 400;
}

.task-date {
    font-size: 14px;
    color: var(--gray-text);
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 24px;
    cursor: pointer;
}

.task-date:hover {
    color: var(--blue-text);
}

.task-contact-initials {
    font-size: 14px;
    color: var(--gray-text);
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 24px;
    margin-right: 0.5rem;
}

.task-date-input {
    font-size: 14px;
    color: var(--dark-text);
    border: 1px solid var(--blue-text);
    border-radius: 4px;
    padding: 0 4px;
    height: 22px;
    line-height: 20px;
    flex-shrink: 0;
    font-family: 'Jost', sans-serif;
}

.task-actions {
    display: flex;
    gap: 0;
    flex-shrink: 0;
}

.task-actions button {
    background: none;
    border: none;
    padding: 0 0.25rem;
    cursor: pointer;
    color: var(--gray-text);
    font-size: 20px;
    line-height: 24px;
    height: 24px;
}

.task-actions button:hover {
    color: var(--dark-text);
}

/* Person group header - matches task items: 25px height */
.person-group-header {
    padding: 0 0.5rem;
    font-size: 14px;
    color: var(--gray-text);
    font-weight: 400;
    background-color: white;
    height: 25px;
    line-height: 24px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Add task button next to contact name */
.contact-add-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--gray-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-add-btn:hover {
    color: var(--blue-text);
    font-weight: 600;
}

/* Bottom filter tabs */
.filter-tabs {
    border-top: 1px solid #e5e7eb;
    padding: 0;
    background-color: white;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    order: 1;
}

.filter-tabs ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0;
}

.filter-tabs li {
    margin: 0;
}

.filter-tabs a,
.filter-tabs button {
    display: block;
    padding: 16px;
    text-decoration: none;
    color: var(--gray-text);
    font-family: 'Jost', sans-serif;
    font-size: 14px;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.filter-tabs a:hover,
.filter-tabs button:hover,
.filter-tabs a.active,
.filter-tabs button.active {
    background-color: var(--light-gray-bg);
    color: var(--blue-text);
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
    padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-text);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Form controls */
.form-group {
    margin-bottom: 0.85rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Jost', sans-serif;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue-text);
    box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.1);
}

/* Buttons */
.btn {
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Jost', sans-serif;
}

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

.btn-primary:hover {
    background-color: #4A9FD4;
}

.btn-secondary {
    background-color: #e5e7eb;
    color: var(--dark-text);
}

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

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

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

/* Navigation */
.nav-scrollable {
    display: flex;
    flex-direction: column;
}

.nav-item {
    padding: 0.5rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
}

.nav-link:hover {
    background-color: #e9ecef;
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* Top row styling */
.top-row a {
    color: #333;
    text-decoration: none;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 13px;
}

.top-row a:hover {
    background-color: #e9ecef;
}

.top-row a.active {
    color: var(--blue-text);
    font-weight: 600;
}

/* NavMenu specific styles */
.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color) !important;
    text-decoration: none;
}

.top-row.navbar {
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 1rem;
}

/* Responsive styles for mobile - input moves to bottom */
@media (max-width: 768px) {
    /* Move input bar to bottom on mobile */
    .task-input-bar {
        order: 1; /* After filter tabs */
    }

    .filter-tabs {
        order: 0; /* Before input bar */
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: auto;
        transform: translateX(-100%);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    }

    .menu-toggle-checkbox:checked ~ .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .menu-toggle-checkbox:checked ~ .sidebar-overlay {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .menu-toggle-button {
        display: inline-block;
    }

    .sidebar-close-button {
        display: inline-block;
    }

    main {
        width: 100%;
    }

    /* Slightly more padding on mobile for touch targets */
    .filter-tabs a,
    .filter-tabs button {
        padding: 12px 10px;
        font-size: 13px;
    }
}

/* Extra styles for portrait orientation on mobile */
@media (max-width: 768px) and (orientation: portrait) and (hover: none) and (pointer: coarse) {
    .top-row {
        padding: 0.15rem 0.5rem;
    }
    
    .top-row-content a {
        font-size: 13px;
        flex-shrink: 0;
    }
}

/* Tablet landscape - keep sidebar visible but narrower */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
}

/* Back button for secondary pages (Settings, Logout, etc.) */
.back-button {
    display: inline-block;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    color: #333 !important;
    line-height: 1;
    text-decoration: none !important;
    margin-right: 0.5rem;
    transition: background-color 0.2s;
}

.back-button:hover {
    background-color: #e9ecef;
    text-decoration: none !important;
    color: #333 !important;
}

/* Hide back button on larger screens where navigation is always visible */
@media (min-width: 769px) {
    .back-button {
        display: none;
    }
}

/* Bootstrap overrides for Identity pages */
/* Override Bootstrap's default blue with our pale blue */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: #4A9FD4 !important;
    border-color: #4A9FD4 !important;
}

/* Override link colors */
a {
    color: var(--blue-text);
}

a:hover {
    color: #4A9FD4;
}

/* Override form focus colors */
.form-control:focus,
.form-select:focus {
    border-color: var(--blue-text);
    box-shadow: 0 0 0 0.25rem rgba(93, 173, 226, 0.25);
}

/* Override checkbox colors */
.form-check-input:checked {
    background-color: var(--blue-text);
    border-color: var(--blue-text);
}

/* Override navbar brand color */
.navbar-brand {
    color: var(--primary-color) !important;
}

/* Modal header with actions */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-header-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* Icon buttons for undo/redo/history */
.btn-icon {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--dark-text);
    line-height: 1;
    transition: all 0.2s;
}

.btn-icon:hover:not(.disabled) {
    background-color: var(--light-gray-bg);
    border-color: var(--blue-text);
    color: var(--blue-text);
}

.btn-icon.active {
    background-color: var(--blue-text);
    border-color: var(--blue-text);
    color: white;
}

.btn-icon.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* History panel */
.history-panel {
    padding: 0.5rem 0;
}

.history-panel h4 {
    margin: 0 0 1rem 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-text);
}

.history-list {
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.history-item.compacted {
    opacity: 0.7;
}

.history-time {
    font-size: 12px;
    color: var(--gray-text);
}

.history-description {
    font-size: 14px;
    color: var(--dark-text);
}

.history-loading,
.history-empty {
    font-size: 14px;
    color: var(--gray-text);
    font-style: italic;
    padding: 1rem 0;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 12px;
}

/* Person list styles */
.person-icon {
    font-size: 1rem;
    margin-right: 0.5rem;
    opacity: 0.6;
}

.person-email {
    margin-left: auto;
    font-size: 13px;
    color: var(--gray-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.delete-confirm-text {
    font-weight: 500;
    color: #dc2626;
    margin-right: 0.5rem;
}

/* Persons page input alignment - different from todo because no checkbox/dot */
.task-input-bar.persons-input-bar input {
    /* Person list: 8px padding + 16px icon + 8px margin = 32px to label */
    /* Input starts at 8px container padding, so need padding-left to reach 32px = 24px */
    /* But visually needs more - try 32px */
    padding-left: 36px;
}

/* Landing page styles */
.landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    overflow-y: auto;
}

.landing-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.landing-title {
    font-size: 3rem;
    font-weight: 600;
    color: var(--blue-text);
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.02em;
}

.landing-tagline {
    font-size: 1.25rem;
    color: var(--gray-text);
    margin: 0;
}

.landing-auth-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    margin-bottom: 2rem;
}

.landing-auth-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-text);
    text-align: center;
    margin: 0 0 1.5rem 0;
}

.landing-auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.landing-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Jost', sans-serif;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.landing-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.landing-btn-oauth {
    background: white;
    border: 1px solid #e2e8f0;
    color: var(--dark-text);
}

.landing-btn-oauth:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    text-decoration: none;
    color: var(--dark-text);
}

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

.landing-btn-primary:hover {
    background: #4A9FD4;
    text-decoration: none;
    color: white;
}

.landing-btn-secondary {
    background: #f1f5f9;
    color: var(--dark-text);
}

.landing-btn-secondary:hover {
    background: #e2e8f0;
    text-decoration: none;
    color: var(--dark-text);
}

.landing-oauth-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.landing-oauth-hint-icon {
    width: 18px;
    height: 18px;
}

.landing-oauth-hint span {
    font-size: 0.8rem;
    color: var(--gray-text);
}

.landing-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    max-width: 600px;
}

.landing-feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.landing-feature-icon {
    width: 24px;
    height: 24px;
    background: var(--blue-text);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.landing-feature-text {
    font-size: 0.9rem;
    color: var(--dark-text);
}

@media (max-width: 480px) {
    .landing-title {
        font-size: 2.25rem;
    }

    .landing-tagline {
        font-size: 1rem;
    }

    .landing-auth-card {
        padding: 1.5rem;
    }

    .landing-features {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
