/* style.css */

:root {
    --md-sys-color-primary: #0061a4;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d1e4ff;
    --md-sys-color-on-primary-container: #001d36;
    --md-sys-color-secondary: #535f70;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #d7e3f8;
    --md-sys-color-on-secondary-container: #101c2b;
    --md-sys-color-tertiary: #6b5778;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #f3daff;
    --md-sys-color-on-tertiary-container: #251431;
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #410002;
    --md-sys-color-background: #fdfcff;
    --md-sys-color-on-background: #1a1c1e;
    --md-sys-color-surface: #fdfcff;
    --md-sys-color-on-surface: #1a1c1e;
    --md-sys-color-surface-variant: #dfe3eb;
    --md-sys-color-on-surface-variant: #42474e;
    --md-sys-color-outline: #73777f;
    --md-sys-color-shadow: #000000;
    --md-sys-elevation-level-0: none;
    --md-sys-elevation-level-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-level-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;
    --modal-overlay-color: rgba(0, 0, 0, 0.32);
    --md-sys-color-primary-rgb: 0, 97, 164;
    --md-sys-color-on-surface-variant-rgb: 66, 71, 78;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.5;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.app-shell {
    display: flex;
    flex-grow: 1;
    height: 100vh;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

header {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: 12px 24px;
    box-shadow: var(--md-sys-elevation-level-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1001;
}

header h1 {
    font-size: 1.375rem;
    font-weight: 400;
    margin-right: auto;
}

main {
    flex-grow: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

button {
    cursor: pointer;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    padding: 10px 24px;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-transform: none;
    transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

button.primary,
form button[type="submit"] {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

button.primary:hover,
form button[type="submit"]:hover {
    box-shadow: var(--md-sys-elevation-level-1);
}

button.outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}

button.outlined:hover {
    background-color: rgba(var(--md-sys-color-primary-rgb), 0.08);
}

button.text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 10px 12px;
}

button.text:hover {
    background-color: rgba(var(--md-sys-color-primary-rgb), 0.08);
}

.icon-button {
    background: none;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}

.icon-button:hover {
    background-color: rgba(var(--md-sys-color-on-surface-variant-rgb), 0.08);
}

input[type="text"],
input[type="datetime-local"],
textarea {
    width: 100%;
    padding: 16px;
    margin-bottom: 8px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-size: 1rem;
}

input[type="text"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
    outline: 2px solid var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

textarea {
    min-height: 112px;
    resize: vertical;
}

form div {
    margin-bottom: 16px;
}

form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.hidden {
    display: none !important;
}

#home-section,
#calendar-section {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#task-list {
    list-style: none;
}

.task-item {
    background: var(--md-sys-color-surface-variant);
    padding: 16px;
    margin-bottom: 12px;
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-level-1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-item .task-info {
    flex-grow: 1;
    margin-right: 16px;
}

.task-item .task-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--md-sys-color-on-surface-variant);
}

.task-item .task-due-date {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.8;
    margin-bottom: 2px;
}

.task-item .task-description {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.9;
    white-space: pre-wrap;
    word-break: break-word;
}

.task-item .complete-btn {
    background-color: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
    padding: 8px 16px;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

#no-tasks-message {
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1rem;
    padding: 32px;
}

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--md-sys-shape-corner-large);
    border: none;
    box-shadow: var(--md-sys-elevation-level-3);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.fab .material-symbols-outlined {
    font-size: 2rem;
    position: absolute;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.fab .fab-icon-open {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

.fab .fab-icon-close {
    transform: rotate(-135deg) scale(0);
    opacity: 0;
}

.fab.open .fab-icon-open {
    transform: rotate(135deg) scale(0);
    opacity: 0;
}

.fab.open .fab-icon-close {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

.fab-menu {
    position: fixed;
    bottom: 96px;
    right: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0s 0.2s linear;
}

.fab-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0s 0s linear;
}

.fab-menu-item {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: var(--md-sys-shape-corner-full);
    padding: 12px 20px;
    box-shadow: var(--md-sys-elevation-level-1);
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fab-menu-item:hover {
    box-shadow: var(--md-sys-elevation-level-2);
    filter: brightness(0.95);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1010;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0s 0.2s linear;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in-out, visibility 0s 0s linear;
}

.modal-content {
    background: var(--md-sys-color-surface);
    padding: 24px;
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-level-3);
    width: 100%;
    max-width: 500px;
    position: relative;
    color: var(--md-sys-color-on-surface);
    transform: scale(0.95);
    transition: transform 0.2s ease-in-out;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 20px;
    color: var(--md-sys-color-on-surface);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1.6rem;
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.15s ease-in-out;
    z-index: 10;
}

.close-btn:hover,
.close-btn:focus-visible {
    background-color: rgba(var(--md-sys-color-on-surface-variant-rgb), 0.08);
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--md-sys-color-surface);
    z-index: 1020;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s linear;
}

.screen:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0s 0s linear;
}

#camera-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #000;
    overflow: hidden;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#cancel-ocr-button.camera-ui-button {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    width: 44px;
    height: 44px;
    background-color: rgba(60, 60, 60, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#camera-controls-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 24px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

#shutter-button {
    width: 72px;
    height: 72px;
    padding: 0;
    border-radius: 50%;
    border: 4px solid #fff;
    background-color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#shutter-button svg {
    fill: #fff;
}

#shutter-button:active {
    transform: scale(0.95);
}

#gallery-button.camera-ui-button,
#switch-camera-button.camera-ui-button {
    width: 48px;
    height: 48px;
    background-color: rgba(60, 60, 60, 0.7);
    border: none;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gallery-button.camera-ui-button svg,
#switch-camera-button.camera-ui-button svg {
    fill: #fff;
}

#ocr-confirm-view {
    width: 100%;
    max-width: 600px;
    padding: 24px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    overflow-y: auto;
    max-height: calc(100vh - 48px);
    margin: 24px;
    box-shadow: var(--md-sys-elevation-level-2);
}

#ocr-confirm-view h2 {
    margin-bottom: 16px;
}

#captured-image-preview {
    display: block;
    width: 100%;
    max-height: 240px;
    margin: 0 auto 16px auto;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-small);
    object-fit: contain;
}

#ocr-status {
    text-align: center;
    margin: 16px 0;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    min-height: 1.5em;
}

#ocr-task-form button {
    margin-top: 12px;
    width: 100%;
    padding: 12px 24px;
}

#request-notification-permission {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    margin-top: 16px;
}

#request-notification-permission:hover {
    box-shadow: var(--md-sys-elevation-level-1);
}

#auth-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--md-sys-color-outline);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    object-fit: cover;
}

.avatar-icon:hover,
.avatar-icon:focus {
    transform: scale(1.1);
    box-shadow: var(--md-sys-elevation-level-1);
    outline: none;
}

.dropdown-menu {
    position: absolute;
    top: 52px;
    right: 0;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-level-2);
    z-index: 1100;
    width: 250px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s linear;
}

.dropdown-menu:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0s linear;
}

.dropdown-header {
    padding: 8px 16px 16px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    margin-bottom: 8px;
}

#dropdown-user-name {
    display: block;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dropdown-user-email {
    display: block;
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: calc(100% - 16px);
    margin: 0 8px;
    padding: 12px 12px;
    background: none;
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    text-align: left;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    transition: background-color 0.15s ease-in-out;
}

.dropdown-item:hover {
    background-color: rgba(var(--md-sys-color-primary-rgb), 0.08);
}

.dropdown-item-icon {
    fill: var(--md-sys-color-on-surface-variant);
    flex-shrink: 0;
}

#nav-rail {
    display: none;
    width: 80px;
    background-color: var(--md-sys-color-surface);
    padding-top: 24px;
    border-right: 1px solid var(--md-sys-color-outline);
}

#nav-rail ul {
    list-style: none;
    flex-direction: column;
}

#nav-rail .nav-button {
    flex-direction: column;
    width: 100%;
    height: 72px;
    background: none;
    border-radius: 0;
    padding: 0;
    gap: 4px;
    color: var(--md-sys-color-on-surface-variant);
    font-family: 'Roboto', sans-serif;
}

.nav-icon-container {
    width: 64px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--md-sys-shape-corner-full);
    transition: background-color 0.2s ease-in-out;
}

.nav-label {
    font-size: 0.75rem;
}

#nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-level-2);
    z-index: 1000;
}

#nav-bar ul {
    list-style: none;
    display: flex;
    height: 100%;
}

#nav-bar li {
    flex-grow: 1;
}

#nav-bar .nav-button {
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: none;
    border-radius: 0;
    padding: 0;
    gap: 4px;
    color: var(--md-sys-color-on-surface-variant);
    font-family: 'Roboto', sans-serif;
}

.nav-button.active .nav-label {
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.nav-button.active .nav-icon-container {
    background-color: var(--md-sys-color-secondary-container);
}

.nav-button.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
    color: var(--md-sys-color-on-secondary-container);
}

#calendar-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.calendar-controls h2 {
    font-size: 1.25rem;
    font-weight: 500;
    text-align: center;
    flex-grow: 1;
}

#prev-month-btn,
#next-month-btn {
    color: var(--md-sys-color-on-surface);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(80px, 1fr);
    gap: 1px;
    background-color: var(--md-sys-color-outline);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-small);
    overflow: hidden;
    flex-grow: 1;
}

.weekday {
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.75rem;
    padding: 8px 4px;
    background-color: var(--md-sys-color-surface-variant);
    text-align: center;
}

.day-cell {
    background-color: var(--md-sys-color-surface);
    padding: 8px;
    position: relative;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.day-number {
    font-size: 0.875rem;
    font-weight: 500;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 4px;
}

.day-cell.today .day-number {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.calendar-tasks {
    list-style: none;
    width: 100%;
    overflow: hidden;
}

.calendar-task-item {
    font-size: 0.75rem;
    padding: 2px 4px;
    margin-bottom: 2px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

.calendar-grid .weekday:first-child,
.calendar-grid .day-cell:nth-child(7n + 1) .day-number {
    color: var(--md-sys-color-error);
}

.calendar-grid .day-cell.today:nth-child(7n + 1) .day-number {
    color: var(--md-sys-color-on-primary);
}

.calendar-grid .weekday:last-child {
    color: var(--md-sys-color-primary);
}

@media (min-width: 601px) {
    #nav-rail {
        display: block;
    }

    #nav-bar {
        display: none;
    }

    #app-container {
        padding-bottom: 16px;
    }
}

@media (max-width: 600px) {
    #app-container {
        padding-bottom: 96px;
    }

    .fab {
        right: 16px;
        bottom: 100px;
    }

    .fab-menu {
        right: 16px;
        bottom: 170px;
    }
}