/* =============================================
   PROFESSIONAL WHITEBOARD STYLES (Ultimate Edition)
   ============================================= */

/* Main Layout */
.main-layout {
    position: relative;
    height: calc(100vh - 80px);
    background-color: #f4f4f9;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #ddd;
}

/* Canvas Area */
.canvas-container {
    width: 100%;
    height: 100%;
    background: #ffffff;
    cursor: crosshair;
}

/* Header Info (Clock) */
.board-header-info {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    z-index: 50;
}

.live-clock {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 8px;
}

.live-date {
    font-size: 0.9rem;
    color: #555;
    margin-top: -5px;
}

.board-watermark {
    position: absolute;
    bottom: 90px;
    right: 20px;
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.15);
    font-weight: bold;
    pointer-events: none;
    user-select: none;
    z-index: 40;
    font-family: 'Poppins', sans-serif;
}

/* =============================================
   FLOATING DOCK TOOLBAR
   ============================================= */

/* Toggle Button */
.toolbar-toggle {
    position: absolute;
    bottom: 30px;
    right: 20px;
    width: 36px;
    height: 24px;
    background: rgba(44, 62, 80, 0.9);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    z-index: 101;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.toolbar-toggle:hover {
    background: rgba(52, 73, 94, 1);
}

.toolbar-toggle i {
    transition: transform 0.3s ease;
}

.toolbar-toggle.collapsed i {
    transform: rotate(180deg);
}

.floating-dock {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.95);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 16px;
    display: flex;
    gap: 6px;
    align-items: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.floating-dock.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.dock-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 3px;
}

/* Buttons */
.dock-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #aeb6bf;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-3px);
}

.dock-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
    transform: translateY(-3px);
}

.dock-btn.magic-box-trigger {
    background: linear-gradient(135deg, #FF9966, #FF5E62);
    color: white;
    font-size: 1.4rem;
}

/* Tool Option Indicators (Little arrow to show popup) */
.dock-btn.has-options::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid rgba(255, 255, 255, 0.7);
}

/* POPUP MENUS (Enhanced) */
.tool-popup {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.98);
    padding: 12px;
    border-radius: 16px;
    display: none;
    flex-direction: column;
    gap: 8px;
    z-index: 110;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-popup.shape-popup {
    max-height: 70vh;
    overflow-y: auto;
    min-width: 280px;
}

.tool-popup.show {
    display: flex;
}

.tool-popup h4 {
    margin: 0 0 5px 0;
    color: #aaa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tool-row {
    display: flex;
    gap: 8px;
}

.tool-option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.tool-option-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tool-option-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Slide Controls */
.slide-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 10px;
}

.slide-counter {
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

/* EXPANDED COLOR PALETTE */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    max-width: 160px;
    align-items: center;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    transform: scale(1.25);
    border-color: white;
    box-shadow: 0 0 8px white;
}

/* Custom Color Picker Input */
.custom-color-wrap {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 2px solid white;
    cursor: pointer;
}

.custom-color-input {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    padding: 0;
    margin: 0;
    border: none;
    cursor: pointer;
}

/* Magic Box Overlay (Existing) */
.magic-box-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

.magic-box-overlay.show {
    display: flex;
}

.magic-box-content {
    background: white;
    width: 600px;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.magic-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.magic-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-radius: 16px;
    border: 2px solid #eee;
    text-decoration: none;
    color: #333;
    background: #f8f9fa;
    cursor: pointer;
}

.magic-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border-radius: 12px;
    color: white;
}

.brand-google {
    background: #4285F4;
}

.brand-gemini {
    background: linear-gradient(135deg, #4E75F5, #9459F5);
}

.brand-gpt {
    background: #10a37f;
}

/* Admin Visibility */
.dock-btn.admin-only,
.magic-card.admin-only {
    display: none !important;
}

body.is-admin .dock-btn.admin-only {
    display: flex !important;
}

body.is-admin .magic-card.admin-only {
    display: flex !important;
}

.whiteboard-wrapper.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    border-radius: 0;
    border: none;
}

/* =============================================
   MATH AI CHAT PANEL STYLES
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&display=swap');

.ai-chat-trigger {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: white !important;
}

.ai-chat-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #1e293b;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-panel.open {
    right: 0;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.ai-chat-title i {
    font-size: 1.3rem;
}

.ai-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.ai-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.ai-welcome-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-welcome-icon i {
    font-size: 2rem;
    color: #6366f1;
}

.ai-welcome h3 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.ai-welcome p {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Message Bubbles */
.ai-message {
    margin-bottom: 20px;
}

.ai-message.user {
    text-align: right;
}

.ai-message .bubble {
    display: inline-block;
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-message.user .bubble {
    background: #6366f1;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message.ai .bubble {
    background: #334155;
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* Handwritten Style Solution */
.ai-solution {
    font-family: 'Caveat', 'Segoe UI Symbol', 'DejaVu Sans', Arial, sans-serif;
    font-size: 1.4rem;
    line-height: 1.8;
    color: #e2e8f0;
    background: #0f172a;
    padding: 20px;
    border-radius: 12px;
    border: 2px dashed #475569;
    margin-top: 10px;
    white-space: pre-wrap;
}

/* Copy to Whiteboard Button */
.copy-to-whiteboard-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-to-whiteboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.copy-to-whiteboard-btn.copied {
    background: #6366f1;
}

/* Input Area */
.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 15px 20px;
    background: #0f172a;
    border-top: 1px solid #334155;
}

.ai-chat-input textarea {
    flex: 1;
    padding: 12px 16px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    transition: border-color 0.2s;
}

.ai-chat-input textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.ai-chat-input textarea::placeholder {
    color: #64748b;
}

.ai-send-btn {
    width: 48px;
    height: 48px;
    background: #6366f1;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-send-btn:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

/* Loading Animation */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 15px 20px;
}

.ai-typing span {
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 500px) {
    .ai-chat-panel {
        width: 100%;
        right: -100%;
    }
}