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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    height: 100%;
    overflow: hidden;
}

.main {
    flex: 1;
    display: flex;
    position: relative;
    background-color: #ffffff;
    height: 100vh;
}

.whiteboard-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fafafa;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

#whiteboard {
    background-color: #ffffff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.controls {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-button {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #666;
}

.tool-button i {
    font-size: 1.2rem;
}

.tool-button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.tool-button.active {
    background: #007AFF;
    color: white;
}

.tool-menu {
    position: fixed;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 999;
    display: none;
    min-width: 240px;
}

.tool-menu.active {
    display: block;
}

.menu-section {
    margin-bottom: 20px;
}

.menu-section:last-child {
    margin-bottom: 0;
}

.menu-section h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
    font-weight: 500;
}

.color-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: #007AFF;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.line-width {
    display: flex;
    align-items: center;
    gap: 12px;
}

.line-width input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
}

.line-width input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #007AFF;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.line-width-value {
    font-size: 0.9rem;
    color: #666;
    min-width: 40px;
    text-align: right;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    display: none;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay-message {
    background: white;
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    font-size: 1.1rem;
    color: #333;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

.user-bubble {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 12px 20px;
  min-width: 180px;
  z-index: 1000;
  font-size: 15px;
  border: 1px solid #e0e0e0;
  transition: box-shadow 0.2s;
}
.user-bubble:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.user-bubble-title {
  font-weight: bold;
  margin-bottom: 6px;
  color: #0070f3;
}
.user-bubble-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.user-bubble-list li {
  margin-bottom: 2px;
}

/* Toast notification styles */
.toast-notification {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 14px 32px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  font-size: 16px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.toast-notification.show {
  opacity: 1;
  pointer-events: auto;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .tool-button {
        width: 56px;
        height: 56px;
        margin: 4px 0;
    }

    .tool-button i {
        font-size: 1.4rem;
    }

    .tool-menu {
        right: 90px;
        padding: 24px;
    }

    .color-option {
        width: 40px;
        height: 40px;
    }

    .menu-section h3 {
        font-size: 1rem;
        margin-bottom: 16px;
    }

    .line-width input[type="range"] {
        height: 6px;
    }

    .line-width input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
}

/* Prevent text selection during drawing */
.whiteboard-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Improve touch feedback */
.tool-button:active {
    transform: scale(0.95);
}

.color-option:active {
    transform: scale(0.95);
}

/* Prevent pull-to-refresh on mobile */
body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Optimize for iPad Pro and other tablets */
@media screen and (min-width: 1024px) and (hover: none) {
    .controls {
        right: 32px;
    }

    .tool-menu {
        right: 100px;
    }

    .tool-button {
        width: 64px;
        height: 64px;
    }

    .tool-button i {
        font-size: 1.6rem;
    }
}

/* Prevent iOS zoom on double tap */
* {
    touch-action: manipulation;
}

/* Improve touch target sizes for better accessibility */
.tool-button,
.color-option,
.line-width input[type="range"] {
    touch-action: manipulation;
}

/* Optimize for Apple Pencil and other styluses */
@media (pointer: fine) {
    .tool-button:hover {
        background: rgba(0, 0, 0, 0.05);
    }
}

/* Prevent unwanted scrolling while drawing */
.whiteboard-container {
    touch-action: none;
    -ms-touch-action: none;
}

/* Optimize for different tablet orientations */
@media screen and (orientation: landscape) and (hover: none) {
    .controls {
        top: 50%;
        transform: translateY(-50%);
    }
}

@media screen and (orientation: portrait) and (hover: none) {
    .controls {
        right: 16px;
        top: auto;
        bottom: 16px;
        transform: none;
    }

    .tool-buttons {
        flex-direction: row;
    }

    .tool-menu {
        right: auto;
        left: 16px;
        bottom: 80px;
        top: auto;
        transform: none;
    }
}

/* iOS-specific styles */
@supports (-webkit-touch-callout: none) {
    .whiteboard-container {
        cursor: none;
    }
    
    .tool-button {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    .tool-button:active {
        opacity: 0.7;
    }
    
    .color-option:active {
        opacity: 0.7;
    }
}

/* Prevent text selection globally */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in input fields */
input, textarea {
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Prevent pull-to-refresh */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Ensure the main container takes full height */
.container {
    height: 100%;
    overflow: hidden;
}

/* Prevent iOS zoom */
@viewport {
    zoom: 1.0;
    min-zoom: 1.0;
    max-zoom: 1.0;
}

/* Prevent iOS text size adjustment */
html {
    -webkit-text-size-adjust: 100%;
} 