/***********************
 * KANTRACK BASE STYLES
 * Global reset, layout, board, notes, buttons
 ***********************/

/* ===== CSS Variables ===== */
:root {
    --notebook-sidebar-width: 400px;
    --accent-color: #3b82f6;
    --success-color: #22c55e;
    --warning-color: #f97316;
    --error-color: #ef4444;
}

/* ===== Global reset/helpers ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 50%, #0d0d0d 100%);
    min-height: 100vh;
    color: #f5f5f5;
    margin: 0;
    padding: 20px;
    padding-top: 80px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Top Header Bar ===== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(135deg, rgba(25, 25, 25, 0.95) 0%, rgba(20, 20, 20, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .back-button,
.top-header .notebook-toggle-btn {
    width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.8) 0%, rgba(40, 40, 40, 0.8) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.top-header .back-button:hover,
.top-header .notebook-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(60, 60, 60, 0.9) 0%, rgba(50, 50, 50, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
}

.top-header .back-button svg,
.top-header .notebook-toggle-btn svg {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    flex-shrink: 0;
    stroke: currentColor;
}

.header-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 8px;
}

.header-logo {
    display: flex;
    align-items: center;
}

.header-logo img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-undo-redo {
    display: flex;
    gap: 6px;
}

.header-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.6) 0%, rgba(40, 40, 40, 0.6) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.6);
    position: relative;
}

.header-action-btn:hover {
    background: linear-gradient(135deg, rgba(60, 60, 60, 0.8) 0%, rgba(50, 50, 50, 0.8) 100%);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.header-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.header-action-btn svg {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
}

.header-trash-btn .trash-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 600;
    background: #e74c3c;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Notebook sidebar open state - shift header content */
body.notebook-sidebar-open .top-header {
    left: var(--notebook-sidebar-width);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.notebook-sidebar-open.sidebar-resizing .top-header {
    transition: none;
}

/* ===== Board layout (Grid keeps columns aligned) ===== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 12px;
}

/* Columns */
.column {
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    min-height: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    backdrop-filter: blur(20px);
}

#todo {
    background: rgba(25, 25, 25, 0.7);
    border-color: rgba(255, 255, 255, 0.06);
}

#inProgress {
    background: rgba(30, 30, 30, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

#onHold {
    background: rgba(35, 35, 35, 0.7);
    border-color: rgba(255, 255, 255, 0.1);
}

#done {
    background: rgba(40, 40, 40, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Column Headers */
.column h2 {
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* Visual feedback during touch/drag (added by JS) */
.column.drop-hover {
    outline: 2px dashed rgba(255, 255, 255, 0.3);
    outline-offset: -6px;
}

/* Column Count */
.column-count {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    margin-left: 6px;
}

/* ===== Notes ===== */
.note {
    background: linear-gradient(135deg, rgba(45, 45, 45, 0.7) 0%, rgba(35, 35, 35, 0.7) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 16px;
    margin: 10px 0;
    color: #f5f5f5;
    display: flex;
    flex-direction: column;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.note:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg, rgba(55, 55, 55, 0.8) 0%, rgba(45, 45, 45, 0.8) 100%);
}

.note:active {
    cursor: grabbing;
}

.note.dragging {
    opacity: 0.5;
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}

.note-content {
    font-weight: 500;
    font-size: 1.1em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.95);
}

.note-text {
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.timestamp {
    margin-top: 10px;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

.worked-time {
    margin-top: 5px;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

/* ===== Buttons & Controls ===== */
button {
    margin-left: 10px;
    background: rgba(60, 60, 60, 0.6);
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

button:hover {
    background: rgba(70, 70, 70, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.export-btn {
    margin-left: 10px;
}

.import-btn {
    margin-left: 10px;
}

.delete-btn {
    background: rgba(80, 40, 40, 0.6);
    border-color: rgba(255, 100, 100, 0.3);
    color: rgba(255, 120, 120, 0.9);
    margin-left: 10px;
}

.delete-btn:hover {
    background: rgba(90, 45, 45, 0.8);
    border-color: rgba(255, 100, 100, 0.5);
    box-shadow: 0 4px 16px rgba(255, 80, 80, 0.2);
}

.clear-btn {
    color: rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.05);
    margin-left: 10px;
}

.clear-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.edit-delete {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.note:hover .edit-delete {
    opacity: 1;
}

.edit-delete button {
    background: none;
    border: none;
    color: inherit;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 1.1em;
    transition: all 0.2s ease;
}

.edit-delete button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.controls-top {
    margin: 16px auto;
    max-width: 1280px;
    padding: 0 12px;
}

.controls-bottom {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.controls-unified-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.controls-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.controls-row-secondary {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.controls-row-main button,
.controls-row-secondary button {
    margin-left: 0;
}

input {
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    background: #2c2c2c;
    color: #e0e0e0;
}

#newNote {
    width: 320px;
    max-width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.4) 0%, rgba(35, 35, 35, 0.4) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #f5f5f5;
    font-size: 0.95em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#newNote:focus {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.5) 0%, rgba(45, 45, 45, 0.5) 100%);
}

#newNote::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* ===== Notes container ===== */
.notes-container {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 12px;
}

.notes-field {
    flex: 1;
    height: 100px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.4) 0%, rgba(35, 35, 35, 0.4) 100%);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    color: #f5f5f5;
    overflow: auto;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.9em;
    resize: vertical;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.notes-field:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.5) 0%, rgba(45, 45, 45, 0.5) 100%);
}

.notes-field::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* ===== Back button (legacy - kept for compatibility) ===== */
.back-to-index {
    display: none;
}

/* ===== Motion preference ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
