/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
}

:root {
    /* Fonts */
    --font-primary: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Light Theme Colors */
    --bg-app: #f8fafc;
    --bg-canvas: #ffffff;
    --color-text: #0f172a;
    --color-muted: #64748b;
    --color-accent: #3b82f6;
    --color-accent-hover: #2563eb;
    
    /* UI Glass Colors */
    --ui-glass-bg: rgba(255, 255, 255, 0.75);
    --ui-glass-border: rgba(255, 255, 255, 0.4);
    --ui-glass-shadow: rgba(15, 23, 42, 0.08);
    
    /* Background Pattern Colors */
    --pat-color: #cbd5e1;

    /* Sticky Note Colors (Light Theme Defaults) */
    --note-yellow: #fef08a;
    --note-yellow-dark: #fef9c3;
    --note-green: #bbf7d0;
    --note-green-dark: #dcfce7;
    --note-blue: #bfdbfe;
    --note-blue-dark: #dbeafe;
    --note-pink: #fbcfe8;
    --note-pink-dark: #fce7f3;
    --note-orange: #fed7aa;
    --note-orange-dark: #ffedd5;
}

.dark-theme {
    /* Dark Theme Colors */
    --bg-app: #0f172a;
    --bg-canvas: #0b0f19;
    --color-text: #f8fafc;
    --color-muted: #94a3b8;
    --color-accent: #60a5fa;
    --color-accent-hover: #3b82f6;
    
    /* UI Glass Colors */
    --ui-glass-bg: rgba(15, 23, 42, 0.65);
    --ui-glass-border: rgba(255, 255, 255, 0.08);
    --ui-glass-shadow: rgba(0, 0, 0, 0.3);
    
    /* Background Pattern Colors */
    --pat-color: #334155;

    /* Sticky Note Colors (Dark Theme Adjustments) */
    --note-yellow: #854d0e;
    --note-yellow-dark: #a16207;
    --note-green: #166534;
    --note-green-dark: #15803d;
    --note-blue: #1e40af;
    --note-blue-dark: #1d4ed8;
    --note-pink: #9d174d;
    --note-pink-dark: #be185d;
    --note-orange: #9a3412;
    --note-orange-dark: #c2410c;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-app);
    color: var(--color-text);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-canvas);
    transition: background-color 0.3s ease;
}

/* Background Patterns (CSS Grid/Dots/Rules) */
.grid-dots {
    background-image: radial-gradient(var(--pat-color) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

.grid-grid {
    background-image: 
        linear-gradient(var(--pat-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--pat-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

.grid-rules {
    background-image: linear-gradient(var(--pat-color) 1px, transparent 1px);
    background-size: 100% 28px;
}

.grid-blank {
    background-image: none;
}

/* Canvas Styling */
#whiteboard-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* Glassmorphism Common Class */
.glass {
    background: var(--ui-glass-bg);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid var(--ui-glass-border);
    box-shadow: 0 10px 30px var(--ui-glass-shadow);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Top Action Bar */
.top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 64px;
    border-radius: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-accent);
}

.logo svg {
    stroke-width: 2.5;
}

.status-indicator {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-muted);
}

.status-indicator::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 8px #10b981;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Icons & Buttons */
.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: background-color 0.2s, transform 0.1s;
}

.btn-icon:hover {
    background-color: rgba(148, 163, 184, 0.15);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--color-accent);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    transform: scale(0.97);
}

/* Bottom Toolbar */
.toolbar-wrapper {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-radius: 20px;
}

.tool-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
    position: relative;
}

.tool-btn:hover {
    background-color: rgba(148, 163, 184, 0.15);
}

.tool-btn.active {
    background-color: var(--color-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.tool-btn:active {
    transform: scale(0.93);
}

.divider {
    width: 1px;
    height: 28px;
    background-color: var(--ui-glass-border);
    margin: 0 4px;
}

/* Tool Groups & Popovers */
.tool-group {
    position: relative;
}

.popover {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--ui-glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--ui-glass-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    padding: 16px;
    width: 200px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.popover.open {
    pointer-events: auto;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.popover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--ui-glass-bg);
}

.popover-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}

/* Color Dot Selection Grid */
.colors-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    box-shadow: inset 0 0 2px rgba(0,0,0,0.1);
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    border-color: var(--color-text);
    transform: scale(1.1);
}

/* Slider Controls */
.size-slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.size-slider-wrapper .label {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.size-slider-wrapper input[type="range"] {
    width: 100%;
    height: 4px;
    background-color: var(--ui-glass-border);
    border-radius: 2px;
    appearance: none;
    outline: none;
}

.size-slider-wrapper input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--color-accent);
    cursor: pointer;
    transition: transform 0.1s;
}

.size-slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Shapes Grid Selection */
.shapes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.shape-option {
    background: transparent;
    border: 1px solid var(--ui-glass-border);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text);
    transition: background-color 0.2s, border-color 0.2s;
}

.shape-option:hover {
    background-color: rgba(148, 163, 184, 0.1);
}

.shape-option.active {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Background Options Popover */
.bg-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bg-option {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: left;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-text);
    transition: background-color 0.2s, border-color 0.2s;
}

.bg-option:hover {
    background-color: rgba(148, 163, 184, 0.1);
}

.bg-option.active {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Sticky Notes Container & Notes */
#notes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.sticky-note {
    position: absolute;
    width: 220px;
    min-height: 220px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08), 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    transition: box-shadow 0.2s, transform 0.2s;
    user-select: text;
    border: 1px solid rgba(0,0,0,0.06);
}

.sticky-note:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
}

.sticky-note.dragging {
    transform: scale(1.02);
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.18);
    opacity: 0.95;
    z-index: 1000 !important;
}

/* Sticky Note Header */
.note-header {
    height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.note-colors-pick {
    display: flex;
    gap: 4px;
}

.note-color-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    cursor: pointer;
}

.note-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(15, 23, 42, 0.4);
    transition: color 0.2s;
}

.dark-theme .note-delete-btn {
    color: rgba(255, 255, 255, 0.4);
}

.note-delete-btn:hover {
    color: #ef4444;
}

/* Sticky Note Content Body */
.note-body {
    flex: 1;
    padding: 14px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    overflow-y: auto;
    outline: none;
    color: #1e293b;
    word-break: break-word;
}

/* Sticky Note Drag / Resize styling */
.note-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 6px, rgba(0,0,0,0.2) 6px);
}

/* Overlays / Welcome Modals */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.welcome-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-content {
    width: 90%;
    max-width: 500px;
    border-radius: 24px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.welcome-overlay.hidden .welcome-content {
    transform: translateY(-20px);
}

.welcome-content h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
}

.welcome-content p {
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.welcome-content ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.welcome-content li {
    font-size: 0.9rem;
    line-height: 1.4;
    padding-left: 24px;
    position: relative;
}

.welcome-content li::before {
    content: "•";
    color: var(--color-accent);
    font-size: 1.5rem;
    position: absolute;
    left: 4px;
    top: -2px;
}

.welcome-content .btn-primary {
    margin-top: 10px;
    justify-content: center;
    height: 48px;
}

/* Scrollbar styles for post-its */
.note-body::-webkit-scrollbar {
    width: 6px;
}

.note-body::-webkit-scrollbar-track {
    background: transparent;
}

.note-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.note-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Tabs Bar Styling (Multi-board) */
.tabs-bar {
    position: absolute;
    top: 96px;
    left: 20px;
    height: 48px;
    border-radius: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 8px;
    max-width: calc(100% - 40px);
    overflow: hidden;
}

.tabs-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    height: 100%;
    align-items: center;
}

.tabs-list::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--color-text);
}

.tab:hover {
    background-color: rgba(148, 163, 184, 0.12);
}

.tab.active {
    background-color: var(--color-accent);
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
}

.tab-title {
    outline: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.tab-title[contenteditable="true"] {
    cursor: text;
    background-color: rgba(255, 255, 255, 0.25);
    color: #0f172a;
}

.dark-theme .tab-title[contenteditable="true"] {
    background-color: rgba(0, 0, 0, 0.3);
    color: #ffffff;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: background-color 0.2s, opacity 0.2s;
}

.tab-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

.tab.active .tab-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

