/**
 * K4LI Windows-Style UI
 * EXACT recreation of Windows WPF application design
 */

/* ==================== DEVICE CARDS (160x200px like Windows) ==================== */

.devices-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    justify-content: center;
}

.device-card {
    width: 160px;
    height: 200px;
    background: #1A1A2E;
    border: 1px solid #FFA500;
    border-radius: 10px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.device-card:hover {
    transform: scale(1.05);
    border-color: #FFD700;
    box-shadow: 0 5px 15px rgba(255, 165, 0, 0.4);
}

/* Device Wallpaper */
.device-wallpaper {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
}

/* Source Badge */
.device-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #FF3B30;
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: bold;
}

.device-badge.apk {
    background: #4CD964;
}

.device-badge.url-hack {
    background: #FF9500;
}

/* Device Info */
.device-info {
    padding: 8px;
    text-align: center;
}

.device-name {
    font-weight: bold;
    font-size: 12px;
    color: white;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-details {
    font-size: 10px;
    color: #CCCCCC;
    margin: 2px 0;
}

.device-details::before {
    content: '📱 ';
    color: #FFA500;
}

.device-details:nth-child(3)::before {
    content: '🌐 ';
}

/* Status Bar */
.device-status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: #4CD964;
    color: white;
    font-size: 9px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 10px 10px;
}

.device-status.offline {
    background: #FF3B30;
}

/* ==================== RIGHT-CLICK CONTEXT MENU ==================== */

.context-menu {
    position: fixed;
    background: #1A1A2E;
    border: 1px solid #FFA500;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu-item {
    padding: 8px 16px;
    color: white;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background: rgba(255, 165, 0, 0.2);
}

.context-menu-item.danger {
    color: #FF3B30;
    font-weight: bold;
}

.context-menu-item.primary {
    font-weight: bold;
}

.context-menu-separator {
    height: 1px;
    background: #FFA500;
    margin: 4px 0;
}

/* ==================== POPUP WINDOWS (800x500px like Windows) ==================== */

.popup-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 500px;
    background: transparent;
    z-index: 9999;
    display: none;
    animation: popupFadeIn 0.3s ease;
}

.popup-window.active {
    display: block;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    display: none;
}

.popup-overlay.active {
    display: block;
}

/* Popup Header Bar (like Windows titlebar) */
.popup-header {
    background: #1A1A20;
    border-bottom: 1px solid white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
}

.popup-title {
    color: white;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-weight: bold;
    font-size: 25px;
    letter-spacing: 2px;
}

.popup-controls {
    display: flex;
    gap: 5px;
}

.popup-btn {
    width: 30px;
    height: 30px;
    border: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.popup-btn:hover {
    opacity: 0.7;
}

.popup-btn.minimize {
    background-image: url('../assets/minimizepic.png');
}

.popup-btn.maximize {
    background-image: url('../assets/maximizepic.png');
}

.popup-btn.close {
    background-image: url('../assets/closepic.png');
}

/* Popup Content */
.popup-content {
    background: linear-gradient(180deg, #1A1A2E 0%, #16213E 50%, #1A1A2E 100%);
    height: calc(100% - 51px);
    overflow-y: auto;
    border-radius: 0 0 6px 6px;
}

/* ==================== DATA TABLES (GridView style) ==================== */

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-grid thead {
    background: #2D2D3A;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-grid th {
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid #FFA500;
}

.data-grid td {
    color: #CCCCCC;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-grid tr:hover {
    background: rgba(255, 165, 0, 0.1);
}

/* ==================== SEARCH BOX ==================== */

.popup-search {
    padding: 15px;
    background: #2D2D3A;
    border-bottom: 1px solid rgba(255, 165, 0, 0.3);
}

.popup-search input {
    width: 100%;
    padding: 10px 15px;
    background: #1A1A2E;
    border: 1px solid #FFA500;
    border-radius: 6px;
    color: white;
    font-size: 14px;
}

.popup-search input::placeholder {
    color: #888;
}

.popup-search input:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

/* ==================== APPS GRID (like Windows) ==================== */

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 15px;
}

.app-card {
    background: #2D2D3A;
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s;
}

.app-card:hover {
    background: #3A3A4A;
    border-color: #FFA500;
    transform: translateY(-2px);
}

.app-card img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.app-name {
    font-size: 11px;
    color: white;
    font-weight: bold;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-package {
    font-size: 9px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-actions {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

.app-actions button {
    flex: 1;
    padding: 5px;
    font-size: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.app-actions button:hover {
    opacity: 0.8;
}

.btn-primary {
    background: #007AFF;
    color: white;
}

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

/* ==================== EMPTY STATE ==================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state img {
    width: 80px;
    height: 80px;
    opacity: 0.5;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #CCCCCC;
}

.empty-state p {
    font-size: 14px;
}

/* ==================== RESPONSIVE (maintain 160px cards) ==================== */

@media (max-width: 1920px) {
    .devices-grid {
        justify-content: center;
    }
}

@media (max-width: 1280px) {
    .popup-window {
        width: 90%;
        height: 90%;
        max-width: 800px;
        max-height: 500px;
    }
}

/* ==================== SCROLLBAR STYLING ==================== */

.popup-content::-webkit-scrollbar {
    width: 8px;
}

.popup-content::-webkit-scrollbar-track {
    background: #1A1A2E;
}

.popup-content::-webkit-scrollbar-thumb {
    background: #FFA500;
    border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: #FFD700;
}

