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

body {
    font-family: Arial, sans-serif;
    background-color: #2c3e50;
    overflow: hidden;
    color: #ecf0f1;
}

/* Кнопка переключения панели инструментов */
.toggle-toolbar {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
}

.toggle-btn {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #ecf0f1;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Вертикальная панель инструментов */
.vertical-toolbar {
    position: fixed;
    top: 35px;
    left: 7px;
    background: #424141;
    border-radius: 8px;
    padding: 7px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.vertical-toolbar.hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
}

.tool-btn {
    width: 31px;
    height: 31px;

   background: #5b5b5b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ff977e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    font-size: 12px;
}

.tool-btn:hover {
    background: #e7a0ff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.tool-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.tool-btn.active:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.tool-btn.danger {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.3);
}

.tool-btn.danger:hover {
    background: rgba(231, 76, 60, 0.3);
}

.tool-btn.danger.active {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* Панели настроек инструментов (отдельные от тулбара) */
.tool-settings-panel {
    position: fixed;
    background: #424141;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1004;
    backdrop-filter: blur(10px);
    display: none;
    animation: slideInRight 0.2s ease;
}

/* Панель толщины */
#thicknessPanel {
    min-width: 160px;
    background: #424141;
}

/* Панель выбора цвета */
#colorPaletteDropdown.tool-settings-panel {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    min-width: 120px;
}

.thickness-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thickness-control label {
    font-size: 12px;
    color: white;
    font-weight: 600;
    text-align: center;
}

#thicknessSlider, #gridSizeSlider {
    width: 140px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#thicknessSlider::-webkit-slider-thumb, #gridSizeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #5b5b5b;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ecf0f1;
    transition: all 0.2s ease;
}

#thicknessSlider::-webkit-slider-thumb:hover, #gridSizeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #5b5b5b;
}

#thicknessValue, #gridSizeValue {
    font-size: 12px;
    color: #ecf0f1;
    font-weight: 600;
    text-align: center;
    background: #5b5b5b;
    padding: 6px 10px;
    border-radius: 4px;
    min-width: 40px;
}

/* Контейнер canvas */
.canvas-container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#whiteboard {
    position: absolute;
    background-color: #ffffff;
    cursor: crosshair;
    touch-action: none;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #424141;
    margin: 15% auto;
    padding: 25px;
    border-radius: 15px;
    width: 350px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #ecf0f1;
}

.modal-content p {
    margin-bottom: 20px;
    color: #bdc3c7;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.btn-danger, .btn-secondary, .btn-primary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #7f8c8d;
    color: white;
}

.btn-secondary:hover {
    background-color: #636e72;
    transform: translateY(-1px);
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

/* Стили для настроек границ */
.border-setting {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.border-setting label {
    margin-bottom: 8px;
    font-weight: 600;
    color: white;
}

.border-setting input[type="number"],
.border-setting input[type="color"] {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ecf0f1;
    font-size: 14px;
}

.border-setting input[type="number"]:focus,
.border-setting input[type="color"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}



/* Добавьте эти стили в CSS */
.tool-btn.active.hand-active {
    background: #9b59b6;
    border-color: #9b59b6;
}

.tool-btn.active.hand-active:hover {
    background: #8e44ad;
}

.border-setting input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.3);
    accent-color: #3498db;
}

/* Информация о масштабе */
#zoom-info {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(44, 62, 80, 0.9);
    color: #ecf0f1;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Анимация выдвижения */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Выпадающие палитры цветов */
.color-palette-dropdown {
    display: none;
    position: absolute;
    left: 100%;
    top: 500;
    background: #424141;
    border-radius: 6px;
    padding: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
    z-index: 1003;
    backdrop-filter: blur(10px);
}

.color-palette-dropdown.show {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    animation: fadeIn 0.2s ease;
}

.color-palette-dropdown .color-option {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.color-palette-dropdown .color-option:hover {
    transform: scale(1.2);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

.color-palette-dropdown .color-option.active {
    border: 2px solid #3498db;
    box-shadow: 0 0 6px rgba(52, 152, 219, 0.8);
}

/* Анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Индикатор страницы */
.page-indicator {
    min-width: 18px;
    font-size: 11px;
    padding: 5px 7px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-top: 6px;
}

/* Стили для формы ввода */
.form-input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ecf0f1;
    font-size: 14px;
    margin: 10px 0;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Анимация для временных линий */
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.temporary-line {
    animation: fadeOut 3s ease-in-out forwards;
}

/* Подсказки */
.tool-btn::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 7px;
    background: rgba(44, 62, 80, 0.95);
    color: #ecf0f1;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1002;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-btn:hover::after {
    opacity: 1;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .toggle-toolbar {
        top: 4px;
        left: 4px;
    }
    
    .toggle-btn {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
    
    .vertical-toolbar {
        top: 28px;
        left: 4px;
        padding: 6px;
        gap: 8px;
    }
    
    .tool-btn {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    .tool-settings-panel {
        padding: 10px;
    }
    
    #thicknessPanel {
        min-width: 140px;
    }
    
    #thicknessSlider, #gridSizeSlider {
        width: 120px;
    }
    
    .thickness-control label {
        font-size: 11px;
    }
    
    #thicknessValue, #gridSizeValue {
        font-size: 11px;
        padding: 5px 8px;
    }

    .rectangle-preview {
        stroke-dasharray: 5, 5;
        animation: dash 1s linear infinite;
    }

    @keyframes dash {
        to {
            stroke-dashoffset: -10;
        }
    }
    
    .modal-content {
        width: 90%;
        margin: 20% auto;
        padding: 20px;
    }
    
    #zoom-info {
        bottom: 7px;
        right: 7px;
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .btn-danger, .btn-secondary, .btn-primary {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .page-indicator {
        font-size: 10px;
        padding: 4px 6px;
    }
    
    /* Скрываем подсказки на мобильных */
    .tool-btn::after {
        display: none;
    }
}

/* Анимации */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.vertical-toolbar {
    animation: slideIn 0.3s ease;
}

.vertical-toolbar.hidden {
    animation: slideOut 0.3s ease;
}

.eraser-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    border: 2px solid red;
    border-radius: 50%;
    background-color: transparent;
    display: none;
}

/* Скрываем стандартный курсор когда ластик активен */
.whiteboard.outside-border {
    cursor: not-allowed !important;
}

canvas {
    cursor: crosshair;
}

/* Панель сетки */
.thickness-panel {
    position: fixed;
    top: 300px;
    left: 52px;
    background: #424141;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
    z-index: 1004;
    backdrop-filter: blur(10px);
    display: none;
    min-width: 126px;
    animation: slideInRight 0.2s ease;
}

.thickness-panel.show {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
