/* ============================================
   Work-Draw — Styles
   ============================================ */

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1e1e1e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Landing Page
   ============================================ */

.landing {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    overflow: auto;
    background: linear-gradient(135deg, #f0f0ff 0%, #f8f9fa 50%, #f0f8ff 100%);
}

.landing .landing-container {
    margin-top: auto;
    margin-bottom: auto;
}

.legal-page .landing-container {
    margin-top: 0;
    margin-bottom: 0;
}

.landing-container {
    max-width: 480px;
    width: 100%;
    padding: 40px 24px;
    text-align: center;
}

.landing-header {
    margin-bottom: 48px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 16px;
}

.landing-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.action-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.action-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.action-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font);
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--text);
    color: white;
    padding: 12px 20px;
}

.btn-secondary:hover {
    opacity: 0.9;
}

.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.join-form {
    display: flex;
    gap: 8px;
}

.join-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

.join-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.landing-footer {
    margin-top: 48px;
}

.landing-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
}

.landing-footer a:hover {
    color: var(--text);
}

/* Impressum */
.impressum-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: left;
}

.legal-page .landing-container {
    max-width: 640px;
}

.impressum-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    margin-top: 24px;
}

.impressum-content h2:first-child {
    margin-top: 0;
}

.impressum-content h3 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

.impressum-content p {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.impressum-content ul {
    margin-bottom: 8px;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.impressum-content li {
    margin-bottom: 4px;
}

.impressum-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.impressum-content a {
    color: var(--primary);
    text-decoration: none;
}

.impressum-content .legal-note {
    font-size: 13px;
    font-style: italic;
    color: var(--text-secondary);
}

/* ============================================
   Drawing App
   ============================================ */

.app {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--surface);
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.topbar-left,
.topbar-center,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-left {
    min-width: 160px;
}

.topbar-right {
    min-width: 160px;
    justify-content: flex-end;
}

.topbar-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.room-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font);
    transition: all 0.1s;
}

.topbar-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.topbar-btn:active {
    transform: scale(0.96);
}

.user-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Toolbar */
.toolbar {
    position: fixed;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.1s;
}

.tool-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
}

.tool-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

/* Style Panel */
.style-panel {
    position: fixed;
    bottom: 60px;
    left: 70px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 220px;
}

.style-section label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type="color"] {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: none;
}

.color-presets {
    display: flex;
    gap: 4px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.1s;
}

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

.color-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

.fill-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
}

.fill-toggle input {
    cursor: pointer;
}

.width-options {
    display: flex;
    gap: 4px;
}

.width-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.1s;
    font-family: var(--font);
    color: var(--text-secondary);
}

.width-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.width-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.dash-options {
    display: flex;
    gap: 4px;
}

.dash-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
    color: var(--text-secondary);
}

.dash-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.dash-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.zorder-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.1s;
    font-family: var(--font);
    color: var(--text-secondary);
}

.zorder-btn:hover {
    border-color: var(--primary);
    color: var(--text);
    background: var(--bg);
}

.zorder-btn:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
}

.zoom-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.zoom-level {
    font-size: 12px;
    font-weight: 600;
    min-width: 44px;
    text-align: center;
    color: var(--text);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Modal / QR Share */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 360px;
    max-width: 90vw;
    overflow: hidden;
    transform: translateY(10px) scale(0.97);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.1s;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.share-link-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.share-link-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg);
    color: var(--text);
    outline: none;
    min-width: 0;
}

.share-link-row .btn {
    padding: 10px 16px;
    font-size: 13px;
    white-space: nowrap;
}

.qr-container {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-container img,
.qr-container canvas {
    display: block;
}

.qr-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.qr-btn {
    padding: 4px 6px;
}

/* Remote Cursors */
.remote-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 99;
    transition: left 0.1s linear, top 0.1s linear;
}

.remote-cursor svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.remote-cursor-label {
    position: absolute;
    top: 20px;
    left: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
}

/* Text Input Overlay */
.text-input-overlay {
    position: fixed;
    z-index: 200;
    background: transparent;
    border: 2px solid var(--primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: var(--font);
    font-size: 16px;
    outline: none;
    min-width: 100px;
    min-height: 32px;
    resize: none;
    overflow: hidden;
}

/* Selection Box */
.selection-box {
    position: fixed;
    border: 1px solid var(--primary);
    background: rgba(79, 70, 229, 0.05);
    pointer-events: none;
    z-index: 50;
}

/* ============================================
   Responsive / Touch
   ============================================ */

@media (max-width: 768px) {
    .btn-label {
        display: none;
    }

    .topbar-left {
        min-width: auto;
    }

    .topbar-right {
        min-width: auto;
    }

    .toolbar {
        top: auto;
        bottom: 56px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 4px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
    }

    .tool-separator {
        width: 1px;
        height: auto;
        margin: 6px 2px;
    }

    .style-panel {
        bottom: 110px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 280px;
    }

    .zoom-controls {
        bottom: 12px;
        right: 12px;
        left: auto;
        transform: none;
    }

    .landing-container {
        padding: 24px 16px;
    }
}

@media (max-width: 480px) {
    .topbar-center {
        display: none;
    }
}

/* Cursor styles per tool */
.cursor-select { cursor: default; }
.cursor-pen { cursor: crosshair; }
.cursor-line { cursor: crosshair; }
.cursor-arrow { cursor: crosshair; }
.cursor-rectangle { cursor: crosshair; }
.cursor-ellipse { cursor: crosshair; }
.cursor-text { cursor: text; }
.cursor-eraser { cursor: crosshair; }
.cursor-eyedropper { cursor: crosshair; }
.cursor-hand { cursor: grab; }
.cursor-hand-active { cursor: grabbing; }
