/* ==========================================================================
   1. GLOBALNE RESETOWANIE I NADPISYWANIE STRUKTURY (Zgodność ze style.css)
   ========================================================================== */
html, body {
    overflow: hidden !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background: #0d0f12 !important;
}

body {
    display: block !important;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
/* ==========================================================================
   2. NAGŁÓWEK APLIKACJI
   ========================================================================== */
.main-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(20, 24, 34, 0.95);
    border-bottom: 1px solid #30363d;
    backdrop-filter: blur(8px);
}

/* ==========================================================================
   3. CANVAS ORAZ TOOLTIPY
   ========================================================================== */
#canvas {
    display: block;
    cursor: crosshair;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#tt {
    position: absolute;
    display: none;
    background: rgba(13, 15, 18, 0.95);
    border: 1px solid #444c56;
    padding: 12px;
    pointer-events: none;
    z-index: 1010;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    max-width: 300px;
}

#counter {
    position: fixed;
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 24, 34, 0.85);
    border: 1px solid #30363d;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    color: #e0e6ed;
    z-index: 990;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   4. PANEL LEWY: WYBÓR KLASY (CLASS PANEL)
   ========================================================================== */
#class-panel {
    position: fixed;
    left: 20px;
    top: 85px;
    width: 260px;
    background: rgba(20, 24, 34, 0.93);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    z-index: 995;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

/* Stan schowany - płynne przesunięcie poza ekran */
#class-panel.collapsed {
    transform: translateX(-285px); /* Szerokość panelu + margines dla pełnego ukrycia */
}

/* Przycisk wysuwania lewego panelu */
#class-panel .toggle-btn {
    position: absolute;
    right: -24px; /* Idealne zakotwiczenie na prawej krawędzi */
    top: 12px;
    width: 24px;
    height: 38px;
    background: rgba(20, 24, 34, 0.95);
    border: 1px solid #30363d;
    border-left: none;
    color: #8892b0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 6px 6px 0;
    font-size: 11px;
    transition: color 0.2s, background 0.2s;
    outline: none;
    padding: 0;
}

#class-panel .toggle-btn:hover {
    background: #1c212e;
    color: #00BFFF;
}

/* ==========================================================================
   5. PANEL PRAWY: PANEL KONTROLNY (CONTROLS PANEL)
   ========================================================================== */
#controls-panel {
    position: fixed;
    right: 20px;
    top: 85px;
    width: 280px;
    background: rgba(20, 24, 34, 0.93);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
    z-index: 995;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

/* Stan schowany - płynne przesunięcie poza ekran */
#controls-panel.collapsed {
    transform: translateX(305px); /* Szerokość panelu + margines dla pełnego ukrycia */
}

/* Przycisk wysuwania prawego panelu */
#controls-panel .toggle-btn {
    position: absolute;
    left: -24px; /* Idealne zakotwiczenie na lewej krawędzi */
    top: 12px;
    width: 24px;
    height: 38px;
    background: rgba(20, 24, 34, 0.95);
    border: 1px solid #30363d;
    border-right: none;
    color: #8892b0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px 0 0 6px;
    font-size: 11px;
    transition: color 0.2s, background 0.2s;
    outline: none;
    padding: 0;
}

#controls-panel .toggle-btn:hover {
    background: #1c212e;
    color: #00BFFF;
}

/* ==========================================================================
   6. ELEMENTY FORMULARZY I UI WEWNĄTRZ PANELI
   ========================================================================== */
.action-panel h3, #class-panel h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #00BFFF;
    border-bottom: 1px solid #30363d;
    padding-bottom: 6px;
}

/* Selektory i labele */
#class-panel label {
    display: block;
    font-size: 11px;
    color: #8b9eb5;
    margin-bottom: 4px;
    margin-top: 10px;
    font-weight: bold;
}

#class-panel select {
    width: 100%;
    background: #0d0f12;
    color: #f5f7fa;
    border: 1px solid #30363d;
    padding: 8px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

#class-panel select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Sekcja zarządzania importem */
.import-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

#import-row {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

#import-row.active {
    display: flex;
}

.import-input {
    width: 100%;
    background: #0d0f12;
    color: #fff;
    border: 1px solid #30363d;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}

.import-input:focus {
    border-color: #00BFFF;
}

/* Przyciski operacyjne */
.control-btn, .import-btn {
    background: #141822;
    color: #9ab0c7;
    border: 1px solid #30363d;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.control-btn:hover, .import-btn:hover {
    background: #00BFFF;
    color: #0d0f12;
    border-color: #00BFFF;
}

/* Moduł wyboru trybu rysowania (Mode Panel) */
.mode-panel {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 4px !important;
    gap: 4px !important;
    background: #0d0f12;
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-bottom: 12px;
}

.mode-btn {
    flex: 1;
    background: transparent;
    color: #8b9eb5;
    border: none;
    padding: 6px 4px !important;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px !important;
    transition: all 0.2s;
    
    /* Zmiany dla ikon SVG i tekstu */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.mode-btn.active {
    background: #21262d;
    color: #ffffff;
}

.mode-btn:nth-child(2).active { color: #ff4500; background: rgba(255, 69, 0, 0.15); } /* WS1 */
.mode-btn:nth-child(3).active { color: #44ff44; background: rgba(68, 255, 68, 0.15); } /* WS2 */

/* Kontenery pomocnicze */
.flex-container {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* ==========================================================================
   7. REGUŁY RESPONSYWNE (MEDIA QUERIES) DLA URZĄDZEŃ MOBILNYCH
   ========================================================================== */
@media (max-width: 768px) {
    #class-panel {
        width: 220px;
        left: 10px;
        top: 110px;
        padding: 10px;
    }
    
    #class-panel.collapsed {
        transform: translateX(-230px); /* Idealne wyrównanie z krawędzią ekranu */
    }

    #controls-panel {
        width: 220px;
        right: 10px;
        top: 110px;
        padding: 10px;
    }
    
    #controls-panel.collapsed {
        transform: translateX(230px); /* Idealne wyrównanie z krawędzią ekranu */
    }
    
    #counter {
        top: 75px;
        font-size: 10px;
        padding: 4px 10px;
        width: auto;
        white-space: nowrap;
        transform: translateX(-50%) scale(0.9);
    }

    .action-btn {
        width: 36px;
        height: 36px;
    }

    .action-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* ==========================================================================
   8. PRZYCISKI AKCJI (Ikony SVG: Copy, GGG, Import) ORAZ ZOOM/CLEAR
   ========================================================================== */
.action-btn {
    background: #141822;
    color: #9ab0c7;
    border: 1px solid #30363d;
    border-radius: 6px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    margin-right: 4px;
}

.action-btn:last-child {
    margin-right: 0;
}

.action-btn:hover {
    background: #00BFFF;
    color: #0d0f12;
    border-color: #00BFFF;
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

/* Wyrównanie w jednym rzędzie dla przycisków typu + / - / Clear */
.button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}

.button-row .control-btn {
    flex: 1; /* Równe rozłożenie szerokości */
}