/* === Whiteboard Theme === */
:root {
    --board-bg: #f5f5f0;
    --board-frame: #4a4a4a;
    --board-frame-light: #6a6a6a;
    --grid-line: #d0d0c8;
    --grid-line-strong: #b0b0a8;
    --marker-shadow: rgba(0,0,0,0.15);
    --tray-metal: linear-gradient(180deg, #8a8a8a 0%, #6a6a6a 30%, #5a5a5a 70%, #4a4a4a 100%);
    --tray-metal-highlight: #a0a0a0;
    --tray-metal-shadow: #3a3a3a;
    --chalk-white: #f0f0eb;
    --text-dark: #333;
    --text-muted: #777;
}

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

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: #2a2a2a;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Board Frame === */
.board-frame {
    flex: 1;
    margin: 16px;
    background: var(--board-bg);
    border: 8px solid var(--board-frame);
    border-radius: 6px;
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.1),
        0 4px 20px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    /* Cork board texture effect */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(200,200,180,0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(180,180,160,0.2) 0%, transparent 50%);
    overflow: hidden;
}

/* === Board Header === */
.board-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--grid-line);
}

.board-title {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-dark);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.month-label {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    min-width: 180px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-btn {
    background: var(--chalk-white);
    border: 2px solid var(--grid-line);
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.15s;
}

.nav-btn:hover {
    background: var(--grid-line);
    border-color: var(--grid-line-strong);
}

/* === Calendar Grid === */
.board-body {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    position: relative;
}

.calendar-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    grid-auto-rows: var(--cell-size, 70px);
    gap: 1px;
    background: var(--grid-line);
}

.day-header {
    background: var(--chalk-white);
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--grid-line-strong);
    min-width: 70px;
}

.day-cell {
    background: var(--board-bg);
    min-width: 70px;
    padding: 4px;
    position: relative;
    cursor: pointer;
    transition: background 0.1s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.day-cell:hover {
    background: rgba(200, 200, 190, 0.3);
}

.day-cell.empty {
    background: rgba(240, 240, 235, 0.5);
    cursor: default;
    min-width: 70px;
    aspect-ratio: 1 / 1;
}

/* === Drawing Canvas Overlay === */
#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#drawing-canvas.active {
    pointer-events: auto;
    cursor: crosshair;
}

#drawing-canvas.tool-eraser {
    pointer-events: auto;
    cursor: cell;
}

.day-cell.today .day-number {
    background: var(--text-dark);
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.day-cell.today .day-number {
    color: white;
}

/* X marks on cells */
.cell-markers {
    flex: 1;
    position: relative;
    min-height: 0;
}

.x-mark {
    position: absolute;
    font-weight: 900;
    line-height: 1;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 2px var(--marker-shadow);
    user-select: none;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.x-mark[data-track-id] {
    pointer-events: auto;
    cursor: pointer;
}

.cell-note {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-word;
    line-height: 1.2;
    overflow: hidden;
    flex-shrink: 0;
}

/* === Metal Tray - Sticky footer === */
.metal-tray {
    background: var(--tray-metal);
    border-top: 3px solid var(--tray-metal-highlight);
    border-bottom: 3px solid var(--tray-metal-shadow);
    padding: 12px 24px;
    margin: 0;
    border-radius: 0;
    box-shadow:
        0 -2px 12px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    width: 100%;
}

.tray-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    margin-right: 8px;
    user-select: none;
}

.tray-tools {
    display: flex;
    gap: 10px;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
}

.tray-divider {
    width: 1px;
    height: 40px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.2), transparent);
}

/* === Marker Buttons === */
.marker-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s;
    position: relative;
}

.marker-btn:hover {
    background: rgba(255,255,255,0.1);
}

.marker-btn.active {
    background: rgba(255,255,255,0.15);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3);
}

.marker-btn .marker-cap {
    width: 28px;
    height: 8px;
    border-radius: 3px 3px 0 0;
    border: 1px solid rgba(0,0,0,0.2);
}

.marker-btn .marker-body {
    width: 22px;
    height: 36px;
    border-radius: 0 0 4px 4px;
    border: 1px solid rgba(0,0,0,0.2);
    border-top: none;
    box-shadow:
        inset 2px 0 4px rgba(255,255,255,0.2),
        inset -2px 0 4px rgba(0,0,0,0.1);
}

.marker-btn .marker-label {
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    max-width: 60px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.marker-btn .marker-edit {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0,0,0,0.3);
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.marker-btn:hover .marker-edit {
    opacity: 1;
}

/* === Generic Tray Tools === */
.tray-tool {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.tray-tool:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.tray-tool.active {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}

.tool-icon {
    font-size: 16px;
    font-weight: 600;
}

.eraser .tool-icon {
    font-size: 20px;
}

.text-tool .tool-icon {
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 20px;
}

.add-habit-tool .tool-icon {
    font-size: 22px;
    font-weight: 300;
}

/* === Stroke Width Slider === */
.stroke-width-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
}

.stroke-width-control label {
    font-size: 9px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stroke-width-control input[type="range"] {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
}

.stroke-width-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    cursor: pointer;
}

.stroke-width-control input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    cursor: pointer;
    border: none;
}

/* === Tray Section Labels === */
.tray-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.25);
    text-transform: uppercase;
    user-select: none;
    padding: 0 4px;
}

.tray-divider-v {
    width: 1px;
    height: 40px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.15), transparent);
}

/* === Modals === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--board-bg);
    border: 3px solid var(--board-frame);
    border-radius: 6px;
    padding: 24px;
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal h3 {
    margin-bottom: 16px;
    color: var(--text-dark);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 16px;
}

.modal input[type="text"],
.modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--grid-line);
    border-radius: 4px;
    background: var(--chalk-white);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.modal input:focus,
.modal textarea:focus {
    outline: none;
    border-color: var(--grid-line-strong);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-save {
    padding: 8px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.btn-save:hover {
    background: #2980b9;
}

.btn-cancel {
    padding: 8px 20px;
    background: var(--grid-line);
    color: var(--text-dark);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-cancel:hover {
    background: var(--grid-line-strong);
}

.btn-delete {
    padding: 8px 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.btn-delete:hover {
    background: #c0392b;
}

/* === Color Swatches === */
.color-picker {
    margin-bottom: 16px;
}

.color-picker label {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.color-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.swatch:hover {
    transform: scale(1.1);
}

.swatch.selected {
    border-color: var(--text-dark);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-dark);
}

/* === Active tool cursor === */
body.tool-marker .day-cell:not(.empty) {
    cursor: crosshair;
}

body.tool-text .day-cell:not(.empty) {
    cursor: text;
}

body.tool-eraser .day-cell:not(.empty) {
    cursor: cell;
}

body.tool-pencil .day-cell:not(.empty) {
    cursor: crosshair;
}

body.tool-eraser-draw .day-cell:not(.empty) {
    cursor: cell;
}

/* === Responsive === */
@media (max-width: 768px) {
    .board-frame {
        margin: 8px;
    }
    .metal-tray {
        margin: 0 8px 8px;
        padding: 8px 12px;
        gap: 8px;
    }
    .day-number {
        font-size: 11px;
    }
}
