* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #0066FF;
    --primary-dark: #0052CC;
    --secondary-color: #00D9FF;
    --bg-primary: #0A0E27;
    --bg-secondary: #131834;
    --bg-card: #1C2347;
    --text-primary: #FFFFFF;
    --text-secondary: #B8C5D6;
    --border-color: #2D3561;
    --focus-color: #0066FF;
    --focus-shadow: 0 0 0 3px rgba(0, 102, 255, 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0F1535 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
}

/* Header */
.header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(19, 24, 52, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo svg {
    margin-right: 15px;
}

.search-hint {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
}

.search-hint svg {
    margin-right: 8px;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 30px 0;
}

.menu {
    display: flex;
    flex-direction: column;
    padding: 0 20px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.3s ease;
    text-align: left;
    outline: none !important;
    margin-bottom: 8px;
}

.menu-item:last-child {
    margin-bottom: 0;
}

.menu-item svg {
    flex-shrink: 0;
    margin-right: 15px;
}

.menu-item:focus,
.menu-item.focused {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-primary);
    outline: none;
    transform: translateX(5px);
    box-shadow: var(--focus-shadow);
}

.menu-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-primary);
}

/* Content */
.content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
    scroll-behavior: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Apps Grid */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    margin: -12px;
}

.app-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding:15px 13px 15px 10px;
    transition: all 0.3s ease;
    display: flex;
    outline: none !important;
    margin: 10px;
}

.app-card:focus,
.app-card.focused {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--focus-shadow), 0 10px 30px rgba(0, 102, 255, 0.3);
    outline: none;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.1), rgba(0, 82, 204, 0.1));
    z-index: 100;
}

.app-icon {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-secondary);
    margin-right: 20px;
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.app-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom:15px;
}

.app-meta {
    display: flex;
    flex-wrap: wrap;
    margin-top: auto;
    margin-left: -6px;
    margin-bottom: -6px;
}

.app-category,
.app-version {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    margin-left: 6px;
    margin-bottom: 6px;
}

/* Info Panel */
.info-panel {
    max-width: 1200px;
}

.info-panel h2 {
    font-size: 32px;
    margin-bottom: 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    margin: -12px;
    margin-bottom: 40px;
}

.info-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    transition: all 0.3s ease;
    margin: 12px;
}

.info-icon {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.info-card h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.info-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-word;
}

/* Controls Guide */
.controls-guide {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
}

.controls-guide h3 {
    font-size: 24px;
    margin-bottom: 20px;
}

.controls-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin: -10px;
}

.control-item {
    display: flex;
    align-items: center;
    margin: 10px;
}

.control-item kbd {
    margin-right: 12px;
}

kbd {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-family: monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 2px 0 var(--border-color);
}

.control-item span {
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    outline: none !important;
}

.modal-close:focus,
.modal-close.focused {
    background: var(--primary-color);
    color: var(--text-primary);
    border-color: var(--primary-color);
    outline: none;
    transform: rotate(90deg);
    box-shadow: var(--focus-shadow);
}

.modal-body {
    padding: 25px 40px 20px 15px;
    display: flex;
}

.modal-icon {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    border-radius: 24px;
    overflow: hidden;
    background: var(--bg-secondary);
    margin-right: 30px;
}

.modal-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-info h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.modal-info p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -6px 16px -6px;
}

.modal-meta span {
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    margin: 0 6px 6px 6px;
}

.install-btn {
    margin-top: 20px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none !important;
}

.install-btn svg {
    margin-right: 10px;
}

.install-btn:focus,
.install-btn.focused {
    transform: translateY(-2px);
    box-shadow: var(--focus-shadow), 0 10px 25px rgba(0, 102, 255, 0.4);
    outline: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 240px 1fr;
    }
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .menu {
        flex-direction: row;
        overflow-x: auto;
    }
    .menu-item {
        margin-right: 8px;
        margin-bottom: 0;
    }
    .apps-grid {
        grid-template-columns: 1fr;
    }
    .modal-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .modal-icon {
        margin-right: 0;
        margin-bottom: 20px;
    }
}

/* Empty message */
.empty-message {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
    color: var(--text-secondary);
}

.empty-message svg {
    margin-bottom: 20px;
}

.empty-message h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.empty-message p {
    font-size: 16px;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: -400px;
    background: linear-gradient(135deg, #00C853, #00E676);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 200, 83, 0.4);
    z-index: 10000;
    transition: right 0.3s ease;
}

.notification.show {
    right: 20px;
}

/* Installed badge */
.installed-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(135deg, #00C853, #00E676);
    color: white;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
    z-index: 10;
}

.app-card.app-installed {
    border-color: #00C853;
}

.app-card.app-installed .app-icon {
    position: relative;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 18px;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}