/**
 * SOS Responsive - Style responsywne
 * 
 * @package SymulatorObwodowSterowania
 * @version 1.0.0
 */

/* ==========================================================================
   Breakpoints:
   - xs: < 576px (telefony)
   - sm: 576px - 767px (telefony landscape)
   - md: 768px - 991px (tablety)
   - lg: 992px - 1199px (małe laptopy)
   - xl: >= 1200px (desktopy)
   ========================================================================== */

/* ==========================================================================
   Desktop duży (xl) - domyślne style
   ========================================================================== */

@media (min-width: 1200px) {
    .sos-simulator-wrapper {
        min-height: 700px;
    }
    
    .sos-toolbar-group {
        padding: 0 12px;
    }
    
    .sos-btn {
        padding: 8px 16px;
    }
}

/* ==========================================================================
   Desktop mały / Laptop (lg)
   ========================================================================== */

@media (max-width: 1199px) {
    :root {
        --sos-panel-width: 260px;
        --sos-toolbar-height: 44px;
    }
    
    .sos-toolbar-group {
        padding: 0 8px;
    }
    
    .sos-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .sos-btn-icon {
        width: 32px;
        height: 32px;
    }
    
    .sos-library-item-icon {
        width: 40px;
        height: 40px;
    }
    
    .sos-library-item-name {
        font-size: 10px;
    }
}

/* ==========================================================================
   Tablet (md)
   ========================================================================== */

@media (max-width: 991px) {
    :root {
        --sos-panel-width: 240px;
        --sos-toolbar-height: 42px;
        --sos-panel-bottom-height: 120px;
    }
    
    .sos-simulator-wrapper {
        min-height: 500px;
    }
    
    /* Toolbar - kompaktowy */
    .sos-toolbar {
        padding: 0 8px;
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .sos-toolbar-group {
        padding: 0 6px;
        flex-shrink: 0;
    }
    
    /* Ukryj niektóre przyciski na tablecie */
    .sos-toolbar .sos-hide-md {
        display: none;
    }
    
    /* Widok kamery - mniejsze przyciski */
    .sos-view-btn {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    /* Mode buttons - kompaktowe */
    .sos-mode-btn {
        padding: 5px 12px;
        font-size: 11px;
    }
    
    /* Biblioteka - 1 kolumna */
    .sos-library-items {
        grid-template-columns: 1fr;
    }
    
    .sos-library-item {
        flex-direction: row;
        padding: 8px 12px;
        text-align: left;
    }
    
    .sos-library-item-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 0;
        margin-right: 10px;
        font-size: 24px;
    }
    
    /* Statusbar - kompaktowy */
    .sos-statusbar {
        font-size: 11px;
        padding: 0 8px;
    }
    
    .sos-statusbar-section {
        padding: 0 8px;
    }
    
    /* Ukryj mniej ważne sekcje statusbar */
    .sos-statusbar .sos-hide-md {
        display: none;
    }
}

/* ==========================================================================
   Telefon landscape (sm)
   ========================================================================== */

@media (max-width: 767px) {
    :root {
        --sos-toolbar-height: 40px;
        --sos-statusbar-height: 28px;
        --sos-panel-bottom-height: 100px;
        --sos-panel-bottom-collapsed: 32px;
    }
    
    .sos-simulator-wrapper {
        min-height: 400px;
    }
    
    /* Panele boczne jako overlay */
    .sos-panel-left,
    .sos-panel-right {
        position: absolute;
        top: var(--sos-toolbar-height);
        bottom: var(--sos-statusbar-height);
        width: 280px;
        min-width: 280px;
        max-width: 85vw;
        z-index: calc(var(--sos-z-panel) + 10);
        box-shadow: var(--sos-shadow-lg);
    }
    
    .sos-panel-left {
        left: 0;
        transform: translateX(-100%);
    }
    
    .sos-panel-right {
        right: 0;
        transform: translateX(100%);
    }
    
    .sos-panel-left.open {
        transform: translateX(0);
    }
    
    .sos-panel-right.open {
        transform: translateX(0);
    }
    
    /* Przyciski otwierania paneli mobilnych */
    .sos-mobile-panel-toggle {
        display: flex !important;
    }
    
    /* Toolbar - bardzo kompaktowy */
    .sos-toolbar {
        padding: 0 4px;
    }
    
    .sos-toolbar-group {
        padding: 0 4px;
        border-right: none;
    }
    
    /* Ukryj teksty przycisków, zostaw ikony */
    .sos-btn .sos-btn-text {
        display: none;
    }
    
    .sos-btn-icon {
        width: 30px;
        height: 30px;
    }
    
    .sos-btn-icon svg,
    .sos-btn-icon img {
        width: 18px;
        height: 18px;
    }
    
    /* Widoki kamery - jeszcze mniejsze */
    .sos-view-btn {
        width: 26px;
        height: 26px;
        font-size: 9px;
    }
    
    /* Mode buttons - tylko ikony */
    .sos-mode-buttons {
        padding: 2px;
    }
    
    .sos-mode-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .sos-mode-btn .sos-mode-text {
        display: none;
    }
    
    /* Panel dolny */
    .sos-panel-bottom {
        height: var(--sos-panel-bottom-height);
        min-height: var(--sos-panel-bottom-height);
    }
    
    .sos-panel-bottom.collapsed {
        height: var(--sos-panel-bottom-collapsed);
        min-height: var(--sos-panel-bottom-collapsed);
    }
    
    .sos-panel-header {
        padding: 6px 10px;
        min-height: 32px;
    }
    
    .sos-panel-title {
        font-size: 12px;
    }
    
    /* Statusbar */
    .sos-statusbar {
        height: var(--sos-statusbar-height);
        font-size: 10px;
    }
    
    /* Ukryj większość sekcji statusbar */
    .sos-statusbar-section:not(.sos-statusbar-main) {
        display: none;
    }
}

/* ==========================================================================
   Telefon portrait (xs)
   ========================================================================== */

@media (max-width: 575px) {
    :root {
        --sos-toolbar-height: 36px;
        --sos-statusbar-height: 24px;
    }
    
    .sos-simulator-wrapper {
        min-height: 350px;
    }
    
    /* Toolbar - minimalny */
    .sos-toolbar {
        justify-content: space-between;
    }
    
    .sos-toolbar-group {
        gap: 2px;
    }
    
    /* Pokaż tylko najważniejsze przyciski */
    .sos-toolbar .sos-hide-xs {
        display: none !important;
    }
    
    .sos-btn-icon {
        width: 28px;
        height: 28px;
    }
    
    /* Widoki kamery - minimalny zestaw */
    .sos-view-buttons {
        gap: 2px;
    }
    
    .sos-view-btn {
        width: 24px;
        height: 24px;
        font-size: 8px;
    }
    
    /* Ukryj niektóre widoki na małych ekranach */
    .sos-view-btn[data-view="left"],
    .sos-view-btn[data-view="right"] {
        display: none;
    }
    
    /* Mode - tylko aktywny widoczny */
    .sos-mode-buttons {
        background: none;
        padding: 0;
    }
    
    .sos-mode-btn:not(.active) {
        display: none;
    }
    
    /* Panele mobilne - pełna szerokość */
    .sos-panel-left,
    .sos-panel-right {
        width: 100%;
        max-width: 100%;
    }
    
    /* Panel dolny - minimalny */
    .sos-panel-bottom {
        height: 80px;
        min-height: 80px;
    }
    
    .sos-panel-bottom.collapsed {
        height: 28px;
        min-height: 28px;
    }
    
    /* Logi - mniejsza czcionka */
    .sos-logs-container {
        font-size: 10px;
    }
    
    .sos-log-time {
        display: none;
    }
    
    /* Statusbar - minimalny */
    .sos-statusbar {
        justify-content: center;
    }
    
    .sos-statusbar-section {
        border: none;
    }
}

/* ==========================================================================
   Orientacja Portrait na urządzeniach mobilnych - ostrzeżenie
   ========================================================================== */

@media (max-width: 767px) and (orientation: portrait) {
    .sos-orientation-warning {
        display: flex;
    }
    
    .sos-canvas-container {
        filter: blur(2px);
        pointer-events: none;
    }
}

/* ==========================================================================
   Wysokość ekranu - dostosowania
   ========================================================================== */

/* Bardzo niski ekran */
@media (max-height: 500px) {
    :root {
        --sos-toolbar-height: 36px;
        --sos-statusbar-height: 24px;
        --sos-panel-bottom-height: 80px;
        --sos-panel-bottom-collapsed: 24px;
    }
    
    .sos-simulator-wrapper {
        min-height: 300px;
    }
    
    .sos-panel-bottom {
        height: var(--sos-panel-bottom-height);
    }
    
    /* Ukryj panel dolny domyślnie */
    .sos-panel-bottom {
        height: var(--sos-panel-bottom-collapsed);
        min-height: var(--sos-panel-bottom-collapsed);
    }
}

/* Wysoki ekran */
@media (min-height: 800px) {
    .sos-simulator-wrapper {
        min-height: 700px;
    }
    
    :root {
        --sos-panel-bottom-height: 180px;
    }
}

/* ==========================================================================
   Obsługa dotyku
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Większe przyciski dla dotyku */
    .sos-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .sos-btn-icon {
        width: 44px;
        height: 44px;
    }
    
    .sos-view-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Większe elementy biblioteki */
    .sos-library-item {
        padding: 12px;
        min-height: 60px;
    }
    
    /* Łatwiejsze klikanie w panelach */
    .sos-category-header {
        padding: 14px 12px;
    }
    
    .sos-accordion-header {
        padding: 14px 12px;
    }
    
    .sos-panel-toggle {
        width: 40px;
        height: 40px;
    }
    
    /* Większy resizer */
    .sos-panel-resizer {
        width: 8px;
    }
    
    .sos-panel-resizer-bottom {
        height: 8px;
    }
    
    /* Usuń efekty hover (nie działają na dotyku) */
    .sos-btn:hover,
    .sos-library-item:hover,
    .sos-category-header:hover {
        background-color: inherit;
    }
    
    /* Aktywne stany dla dotyku */
    .sos-btn:active {
        background-color: rgba(255, 255, 255, 0.2);
    }
    
    .sos-library-item:active {
        background-color: var(--sos-bg-medium);
        border-color: var(--sos-primary);
    }
}

/* ==========================================================================
   High DPI / Retina
   ========================================================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Cieńsze linie */
    .sos-toolbar,
    .sos-panel-left,
    .sos-panel-right,
    .sos-panel-bottom,
    .sos-statusbar {
        border-width: 0.5px;
    }
}

/* ==========================================================================
   Prefers reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .sos-orientation-icon {
        animation: none;
    }
    
    .sos-loading-spinner {
        animation: none;
        border-top-color: var(--sos-primary);
    }
}

/* ==========================================================================
   Prefers color scheme (dark/light)
   ========================================================================== */

@media (prefers-color-scheme: light) {
    /* Można dodać alternatywny jasny motyw */
    /* Na razie zostawiamy ciemny jako domyślny */
}

/* ==========================================================================
   Print styles
   ========================================================================== */

@media print {
    .sos-simulator-wrapper {
        display: none !important;
    }
    
    .sos-print-message {
        display: block !important;
        padding: 20px;
        text-align: center;
        font-size: 14px;
        color: #333;
    }
    
    .sos-print-message::before {
        content: 'Symulator obwodów sterowania - do użycia interaktywnego w przeglądarce.';
    }
}

/* ==========================================================================
   Klasy pomocnicze dla responsywności
   ========================================================================== */

/* Ukrywanie na różnych breakpointach */
@media (max-width: 575px) {
    .sos-hide-xs { display: none !important; }
}

@media (min-width: 576px) and (max-width: 767px) {
    .sos-hide-sm { display: none !important; }
}

@media (min-width: 768px) and (max-width: 991px) {
    .sos-hide-md { display: none !important; }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .sos-hide-lg { display: none !important; }
}

@media (min-width: 1200px) {
    .sos-hide-xl { display: none !important; }
}

/* Pokazywanie na różnych breakpointach */
.sos-show-xs,
.sos-show-sm,
.sos-show-md,
.sos-show-lg,
.sos-show-xl {
    display: none !important;
}

@media (max-width: 575px) {
    .sos-show-xs { display: flex !important; }
}

@media (min-width: 576px) and (max-width: 767px) {
    .sos-show-sm { display: flex !important; }
}

@media (min-width: 768px) and (max-width: 991px) {
    .sos-show-md { display: flex !important; }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .sos-show-lg { display: flex !important; }
}

@media (min-width: 1200px) {
    .sos-show-xl { display: flex !important; }
}

/* Przyciski mobilne do otwierania paneli */
.sos-mobile-panel-toggle {
    display: none;
}

@media (max-width: 767px) {
    .sos-mobile-panel-toggle {
        display: flex;
    }
}