/* ===========================
   CSS Reset & Base Styles
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ===========================
   Zone Color Variables
   =========================== */
:root {
    --zone-hours: rgba(255, 68, 68, 0.15);      /* Red */
    --zone-day: rgba(255, 136, 68, 0.12);       /* Orange-red */
    --zone-days: rgba(255, 221, 68, 0.10);      /* Yellow */
    --zone-week: rgba(136, 255, 68, 0.10);      /* Yellow-green */
    --zone-weeks: rgba(68, 255, 136, 0.10);     /* Green */
    --zone-months: rgba(68, 221, 255, 0.10);    /* Cyan */
    --zone-someday: rgba(136, 68, 255, 0.08);   /* Purple */

    --boundary-color: rgba(0, 0, 0, 0.15);
    --task-bg: rgba(255, 255, 255, 0.9);
    --task-shadow: rgba(0, 0, 0, 0.2);
    --task-age-bg: rgba(0, 0, 0, 0.6);
    --task-age-text: #ffffff;
}

/* ===========================
   SVG Boundary Overlay
   =========================== */
.boundary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

.boundary-line {
    fill: none;
    stroke: var(--boundary-color);
    stroke-width: 2;
}

/* ===========================
   Plot Container
   =========================== */
.plot-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #f5f5f5;
    cursor: crosshair;
}

/* ===========================
   Task Blocks
   =========================== */
.task-block {
    position: absolute;
    display: flex;
    align-items: stretch;
    min-width: 120px;
    max-width: 250px;
    height: 60px;
    background: var(--task-bg);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    box-shadow: 2px 4px 12px var(--task-shadow);
    cursor: grab;
    user-select: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    overflow: hidden;
    z-index: 100; /* Base z-index, will be overridden by inline style */
}

/* Pointer corner - default top-right */
.task-block[data-pointer="top-right"] {
    border-radius: 12px 0 12px 12px; /* top-left, top-right (sharp), bottom-right, bottom-left */
}

/* Pointer corner - top-left (near left edge) */
.task-block[data-pointer="top-left"] {
    border-radius: 0 12px 12px 12px; /* top-left (sharp), top-right, bottom-right, bottom-left */
}

/* Pointer corner - bottom-right (near bottom edge) */
.task-block[data-pointer="bottom-right"] {
    border-radius: 12px 12px 0 12px; /* top-left, top-right, bottom-right (sharp), bottom-left */
}

/* No pointer corner - all rounded (expanded form) */
.task-block[data-pointer="none"] {
    border-radius: 12px; /* All corners rounded */
}

/* Hover state */
.task-block:hover {
    transform: scale(1.05);
    box-shadow: 3px 6px 16px var(--task-shadow);
}

/* Dragging state */
.task-block.dragging {
    opacity: 0.8;
    cursor: grabbing;
    box-shadow: 4px 8px 20px rgba(0, 0, 0, 0.3);
}

/* ===========================
   Task Age Tab
   =========================== */
.task-age-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    background: var(--task-age-bg);
    color: var(--task-age-text);
    font-size: 10px;
    font-weight: 600;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    border-radius: 8px 0 0 8px;
    flex-shrink: 0;
    padding: 4px 0;
}

/* ===========================
   Task Title
   =========================== */
.task-title {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding: 11px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    line-height: 1.4;
    max-height: 50px; /* Allow 2 full lines (39.2px) + padding (22px) with buffer */
}

/* ===========================
   Expanded Task Form
   =========================== */
.task-form-expanded {
    display: flex;
    flex-direction: column;
    width: 280px;
    padding: 16px;
    gap: 12px;
}

.task-block.expanded {
    width: 280px;
    height: auto;
    min-height: 180px;
    cursor: default;
    z-index: 10000 !important; /* Always on top when expanded */
}

.task-title-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.task-title-input:focus {
    border-color: #4CAF50;
}

.task-datetime-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.task-datetime-input:focus {
    border-color: #4CAF50;
}

.task-form-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.task-form-buttons button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-ok {
    background: #4CAF50;
    color: white;
}

.btn-ok:hover {
    background: #45a049;
}

.btn-done {
    background: #2196F3;
    color: white;
}

.btn-done:hover {
    background: #0b7dda;
}

.btn-undo {
    background: #ff9800;
    color: white;
}

.btn-undo:hover {
    background: #e68a00;
}

.btn-trash {
    background: #f44336;
    color: white;
    flex: 0.5;
}

.btn-trash:hover {
    background: #da190b;
}

.btn-trash::before {
    content: '🗑';
    font-size: 14px;
}

/* ===========================
   Utility Classes
   =========================== */
.hidden {
    display: none !important;
}

.no-interaction {
    pointer-events: none;
}

/* ===========================
   Custom Scrollbar (if needed)
   =========================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* ===========================
   Hamburger Menu
   =========================== */

/* Hamburger Icon */
.hamburger-icon {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 9999;
    padding: 8px;
}

.hamburger-icon:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 3px 6px 16px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: #333;
    border-radius: 2px;
    transition: all 0.2s ease;
}

/* Menu Panel */
.hamburger-menu {
    position: fixed;
    bottom: 75px;
    left: 20px;
    width: 220px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.2);
    padding: 8px;
    z-index: 9998;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: all 0.2s ease;
}

.hamburger-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Menu Items */
.menu-item {
    padding: 8px 12px;
}

.menu-toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.menu-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.menu-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.menu-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 4px 0;
}

.menu-button {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    background: #f44336;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.menu-button:hover {
    background: #da190b;
}

.menu-button:active {
    transform: scale(0.98);
}

/* Specific button colors */
#export-backup-btn,
#import-backup-btn {
    background: #2196F3;
}

#export-backup-btn:hover,
#import-backup-btn:hover {
    background: #0b7dda;
}

/* Highlighted Task Styling (in progress) */
.task-block.highlighted {
    background: rgba(255, 245, 200, 0.95);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.6), 2px 4px 12px var(--task-shadow);
}

.task-block.highlighted .task-age-tab {
    background: rgba(255, 152, 0, 0.85);
}

/* Completed Task Styling - ghostly appearance */
.task-block.completed {
    opacity: 0.25;
    background: rgba(200, 200, 200, 0.5);
    box-shadow: none;
    pointer-events: auto;
}

.task-block.completed:hover {
    opacity: 0.5;
    transform: none;
    box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.1);
}

.task-block.completed .task-title {
    text-decoration: line-through;
    color: #888;
}

.task-block.completed .task-age-tab {
    background: rgba(0, 0, 0, 0.3);
}

/* Trashed Task Styling */
.task-block.trashed {
    opacity: 0.5;
    background: rgba(150, 150, 150, 0.7);
    border: 2px dashed rgba(0, 0, 0, 0.3);
}

.task-block.trashed .task-title {
    color: #888;
}

.task-block.trashed .task-age-tab {
    background: rgba(0, 0, 0, 0.4);
}

/* Restore and Delete Forever Buttons */
.btn-restore {
    background: #4CAF50;
    color: white;
}

.btn-restore:hover {
    background: #45a049;
}

.btn-delete-permanent {
    background: #333;
    color: white;
}

.btn-delete-permanent:hover {
    background: #000;
}

/* ===========================
   Help Modal
   =========================== */

.help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.help-modal.open {
    display: flex;
}

.help-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px 32px;
    max-width: 320px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.help-modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.help-modal-close:hover {
    color: #333;
}

.help-modal-content h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #333;
}

.help-modal-subtitle {
    margin: 12px 0 8px 0;
    font-size: 13px;
    color: #666;
}

.help-modal-subtitle:first-of-type {
    margin-top: 0;
}

.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 4px;
}

.shortcuts-table tr {
    border-bottom: none;
}

.shortcuts-table td {
    padding: 6px 0;
    font-size: 14px;
    color: #333;
    vertical-align: middle;
}

.shortcuts-table td:first-child {
    width: 90px;
    padding-right: 12px;
}

.shortcut-key {
    display: inline-block;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
    font-size: 11px;
    font-weight: 500;
    color: #555;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.help-modal-hint {
    margin: 16px 0 0 0;
    font-size: 12px;
    color: #999;
    text-align: center;
}
