/* Гарантия что body занимает всю высоту */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'MS Sans Serif', Arial, sans-serif;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.apps-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    pointer-events: none;
    padding: 20px 20px 140px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-content: start;
    z-index: 1;
    box-sizing: border-box;
}

.app-window {
    pointer-events: all;
    background: #c0c0c0;
    border: 3px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-right-color: #808080;
    border-bottom-color: #808080;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    break-inside: avoid;
}

.app-window .title-bar {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: white;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    height: 22px;
    border-bottom: 1px solid #000080;
    cursor: default;
    user-select: none;
}

.app-window .window-body {
    flex: 1;
    padding: 20px;
    background: #c0c0c0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-preview {
    height: 200px;
    background: #c0c0c0;
    border: 2px inset;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

/* СТИЛИ ДЛЯ РАСТЯГИВАНИЯ ФОТОК */
.app-preview img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

.app-preview .default-icon {
    font-size: 60px;
    color: #000080;
    position: relative;
    z-index: 1;
}

.app-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.app-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
    color: #000;
    text-align: center;
}

.app-description {
    font-size: 13px;
    line-height: 1.4;
    color: #000;
    margin-bottom: 15px;
    flex: 1;
    text-align: center;
    overflow-y: auto;
    max-height: 80px;
}

.app-button {
    align-self: center;
    padding: 10px 25px;
    border: 2px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-right-color: #808080;
    border-bottom-color: #808080;
    background: #c0c0c0;
    cursor: pointer;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 13px;
    font-weight: bold;
    min-width: 120px;
    flex-shrink: 0;
}

.app-button:hover {
    background: #d0d0d0;
}

.app-button:active {
    border-top-color: #808080;
    border-left-color: #808080;
    border-right-color: #dfdfdf;
    border-bottom-color: #dfdfdf;
}

/* Стили для кнопок окна */
.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 18px;
    height: 16px;
    border: 1px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-right-color: #808080;
    border-bottom-color: #808080;
    background: #c0c0c0;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

/* Символы на кнопках */
.title-bar-controls button[aria-label="Minimize"]::after {
    content: "_";
    color: #000;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
}

.title-bar-controls button[aria-label="Maximize"]::after {
    content: "□";
    color: #000;
    font-size: 8px;
    font-weight: bold;
}

.title-bar-controls button[aria-label="Close"]::after {
    content: "×";
    color: #000;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 1px;
}

.title-bar-controls button:active {
    border-top-color: #808080;
    border-left-color: #808080;
    border-right-color: #dfdfdf;
    border-bottom-color: #dfdfdf;
}

/* Социальная панель */
.social-panel {
    position: fixed !important;
    bottom: 10px !important;
    right: 10px !important;
    z-index: 99999 !important;
    pointer-events: all !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: flex-end !important;
}

.social-window {
    width: 90px;
    background: #c0c0c0;
    border: 2px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-right-color: #808080;
    border-bottom-color: #808080;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.social-window .title-bar {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: white;
    padding: 1px 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    font-weight: bold;
    height: 14px;
    border-bottom: 1px solid #000080;
    cursor: default;
}

.social-window-body {
    padding: 8px 4px;
    background: #c0c0c0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 50px;
}

.social-icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px;
    border: 1px solid transparent;
    width: 100%;
    height: 100%;
}

.social-icon-container:hover {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #808080;
}

.social-icon-img {
    width: 32px !important;
    height: 32px !important;
    object-fit: contain !important;
    object-position: center !important;
    display: block;
}

.social-fallback {
    width: 32px !important;
    height: 32px !important;
    background: linear-gradient(135deg, #000080, #1084d0);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border-radius: 2px;
}

.social-label {
    font-size: 9px;
    font-weight: bold;
    color: #000;
    text-align: center;
    font-family: 'MS Sans Serif', sans-serif;
    text-shadow: 1px 1px 0px #fff;
    line-height: 1;
    padding: 2px 0;
    width: 100%;
    background: #c0c0c0;
    border-top: 1px solid #808080;
}

/* Стили для кнопок окон соцпанели */
.social-window .title-bar-controls {
    display: flex;
    gap: 1px;
}

.social-window .title-bar-controls button {
    width: 12px;
    height: 10px;
    border: 1px solid;
    border-top-color: #dfdfdf;
    border-left-color: #dfdfdf;
    border-right-color: #808080;
    border-bottom-color: #808080;
    background: #c0c0c0;
    font-size: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 1024px) {
    .apps-container {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 15px;
        padding: 15px 15px 120px 15px;
    }
}

@media (max-width: 768px) {
    .apps-container {
        grid-template-columns: 1fr;
        padding: 10px 10px 100px 10px;
        gap: 12px;
    }
    
    .app-window {
        min-height: 350px;
    }
    
    .app-preview {
        height: 160px;
        margin-bottom: 12px;
    }
    
    .app-preview .default-icon {
        font-size: 50px;
    }
    
    .app-title {
        font-size: 15px;
        margin-bottom: 8px;
    }
    
    .app-description {
        font-size: 12px;
        margin-bottom: 12px;
        line-height: 1.3;
        max-height: 70px;
    }
    
    .app-button {
        padding: 8px 20px;
        font-size: 12px;
        min-width: 110px;
    }
    
    .social-panel {
        bottom: 5px;
        right: 5px;
        gap: 8px;
    }
    
    .social-window {
        width: 80px;
    }
    
    .social-window-body {
        padding: 6px 3px;
        min-height: 45px;
    }
    
    .social-icon-img {
        width: 28px !important;
        height: 28px !important;
    }
}

@media (max-width: 480px) {
    .apps-container {
        padding: 8px 8px 90px 8px;
        gap: 10px;
    }
    
    .app-window {
        min-height: 320px;
    }
    
    .app-window .window-body {
        padding: 15px;
    }
    
    .app-preview {
        height: 140px;
        margin-bottom: 10px;
    }
    
    .app-preview .default-icon {
        font-size: 40px;
    }
    
    .app-title {
        font-size: 14px;
    }
    
    .app-description {
        font-size: 11px;
        margin-bottom: 10px;
        max-height: 60px;
    }
    
    .app-button {
        padding: 7px 18px;
        font-size: 11px;
        min-width: 100px;
    }
    
    .social-panel {
        bottom: 3px;
        right: 3px;
        gap: 6px;
    }
    
    .social-window {
        width: 70px;
    }
    
    .social-window .title-bar {
        font-size: 8px;
        height: 12px;
    }
    
    .social-window-body {
        padding: 4px 2px;
        min-height: 40px;
    }
    
    .social-icon-img {
        width: 24px !important;
        height: 24px !important;
    }
    
    .social-label {
        font-size: 8px;
    }
}

/* Ориентация телефона */
@media (max-width: 768px) and (orientation: landscape) {
    .apps-container {
        grid-template-columns: repeat(2, 1fr);
        padding: 10px 10px 80px 10px;
    }
    
    .app-window {
        min-height: 300px;
    }
    
    .app-preview {
        height: 120px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .apps-container {
        padding: 5px 5px 80px 5px;
    }
    
    .app-window .window-body {
        padding: 12px;
    }
    
    .app-preview {
        height: 120px;
    }
    
    .social-panel {
        gap: 5px;
    }
    
    .social-window {
        width: 65px;
    }
}

/* Поддержка touch устройств */
@media (hover: none) and (pointer: coarse) {
    .app-button:hover {
        background: #c0c0c0;
    }
    
    .app-button:active {
        background: #d0d0d0;
        border-top-color: #808080;
        border-left-color: #808080;
        border-right-color: #dfdfdf;
        border-bottom-color: #dfdfdf;
    }
    
    .social-icon-container:hover {
        background: transparent;
        border: 1px solid transparent;
    }
    
    .social-icon-container:active {
        background: rgba(255, 255, 255, 0.3);
        border: 1px solid #808080;
    }
}