/**
 * TSEE WebUI 应用管理页面样式
 * 基于 Material Design 3 设计系统
 */

.settings-content {
    position: relative;
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

#settings-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.app-list-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-bottom: 80px; 
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.search-container {
    flex-shrink: 0;
    margin-bottom: 12px;
}

.setting-item .setting-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--on-surface);
}

.setting-item .setting-value {
    font-size: 14px;
    color: var(--on-surface-variant);
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-variant);
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: var(--on-surface-variant);
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(24px);
    background-color: var(--on-primary);
}

.app-icon-container {
    position: relative;
    width: 32px;
    height: 32px;
    margin-right: 16px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.app-icon-loader {
    width: 100%;
    height: 100%;
    background: var(--outline-variant);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-icon-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-icon-img.loaded {
    opacity: 1;
}

.search-and-help {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--surface-container-high);
    border: 1px solid var(--outline-variant);
    border-radius: 20px;
    font: var(--body-m);
    color: var(--on-surface);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 103, 80, 164), 0.2);
}

.search-input::placeholder {
    color: var(--on-surface-variant);
}

.help-btn {
    padding: 12px;
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    border: none;
    border-radius: 12px;
    font: var(--body-m);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.help-btn:hover {
    background: var(--secondary-container);
    opacity: 0.9;
}

.help-btn:active {
    transform: scale(0.98);
}

.option-group {
    background: var(--surface-container);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--on-surface-variant);
}

.empty-state .material-symbols-rounded {
    font-size: 48px;
    color: var(--outline);
    margin-bottom: 12px;
}

.app-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 60px;
}

.app-list-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: none;
    transition: all 0.2s ease;
    min-height: 72px;
}

.app-list-item:last-child {
    border-bottom: none;
}

.app-list-item:hover {
    background-color: var(--surface-container);
}

.app-list-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding-right: 12px;
    overflow: hidden;
}

.app-list-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--on-surface);
    line-height: 1.2;
    margin-bottom: 0;
}

.app-list-subtitle {
    font-size: 13px;
    color: var(--on-surface-variant);
    opacity: 0.8;
    line-height: 1.2;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.app-list-badges {
    margin-top: 4px;
    display: flex;
    gap: 6px;
}

.app-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    line-height: 1.4;
}

.badge-user {
    background-color: #EDD7FB;
    color: #212C3E;
}

.badge-system {
    background-color: #D9E3F8;
    color: #212C3E;
}

.app-icon-container {
    width: 40px;
    height: 40px;
    margin-right: 16px;
    border-radius: 10px;
}

.app-list-switch {
    margin-left: 8px;
    align-self: center;
    flex-shrink: 0;
}

.app-list-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
    font-size: 32px !important;
}

.app-list-icon .material-symbols-rounded {
    font-size: 32px !important;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--on-surface-variant);
    font-size: 20px;
}

.search-input-wrapper {
    position: relative;
}

input[type="range"] + output {
    margin-left: 8px;
    font: var(--label-m);
    color: var(--on-surface-variant);
}

@media (min-width: 768px) {
    .settings-content {
        padding: 20px;
    }
}

.settings-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: none;
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.settings-loading-content {
    background: var(--surface-container-high);
    border-radius: 24px;
    padding: 32px;
    text-align: center;
    min-width: 280px;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--outline-variant);
    box-shadow: none !important;
    filter: none !important;
}

.settings-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--outline);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.settings-loading-text {
    font: var(--title-m);
    color: var(--on-surface);
    margin-bottom: 16px;
}

.settings-loading-progress-container {
    width: 100%;
    margin-top: 16px;
    display: none;
}

.settings-loading-progress {
    width: 100%;
    height: 6px;
    background: var(--outline-variant);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.settings-loading-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.settings-loading-progress-text {
    font: var(--body-s);
    color: var(--on-surface-variant);
    text-align: center;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes progressBar {
    0% { 
        transform: translateX(-100%); 
        width: 30%; 
    }
    50% { 
        transform: translateX(100%); 
        width: 60%; 
    }
    100% { 
        transform: translateX(300%); 
        width: 30%; 
    }
}

.loading-placeholder {
    text-align: center;
    padding: 48px 0;
    color: var(--on-surface-variant);
    font: var(--body-m);
    color: transparent;
}

@keyframes modalSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.settings-menu {
    position: fixed;
    top: 70px;
    right: 16px;
    background: var(--surface-container-high);
    border-radius: 16px;
    padding: 16px;
    min-width: 240px;
    box-shadow: 0 8px 24px oklch(0 0 0 / 0.2);
    border: 1px solid var(--outline-variant);
    z-index: 1001;
    animation: modalSlideUp 0.2s ease-out;
    backdrop-filter: blur(20px);
}

.settings-menu-title {
    font: var(--title-m);
    color: var(--on-surface);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--outline-variant);
}

.settings-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 8px 0;
    cursor: default;
}

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

.settings-menu-item-label {
    flex: 1;
    margin-right: 16px;
}

.settings-menu-item-title {
    font: var(--title-s);
    color: var(--on-surface);
    margin-bottom: 4px;
}

.settings-menu-item-desc {
    font: var(--body-s);
    color: var(--on-surface-variant);
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.page-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--surface-container-high);
    border: 1px solid var(--outline-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-action-btn:hover {
    background: var(--surface-container);
    transform: translateY(-2px);
}

.page-action-btn:active {
    transform: translateY(0);
}

.page-action-btn .material-symbols-rounded {
    font-size: 20px;
    color: var(--on-surface);
}

.settings-page-active .app-nav {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: transform 0.3s ease, opacity 0.3s ease !important;
}

.settings-page-active .app-header.header-solid {
    background-color: var(--surface) !important;
    border-bottom: 1px solid var(--outline-variant);
}

.settings-page-active #main-content {
    overflow: hidden;
}

.settings-page-active .settings-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.settings-page-active .app-nav {
    z-index: 100;
    position: relative;
    background: var(--surface);
    border-top: 1px solid var(--outline-variant);
}