/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;          /* 空间不足时换行而不是互相挤压 */
    gap: 12px 18px;
    padding: 15px 40px;
    margin-bottom: 20px;
    background: rgba(30, 30, 60, 0.95) !important;
    /* 加深背景颜色，确保对比度 */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff !important;
    /* 强制白色 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    white-space: nowrap;      /* 标题不换行（修复“小智云电/脑”竖排断行） */
    flex-shrink: 0;
}

.device-notice {
    color: rgba(255, 255, 255, 0.84);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
    max-width: 360px;
    flex: 1 1 260px;          /* 可伸缩，避免挤压两侧 */
    min-width: 0;
}

.auth-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;          /* 按钮放不下时整行换行，而不是按钮内部竖排 */
    gap: 10px;
    margin-left: auto;
}

.auth-nav .btn {
    text-decoration: none;
    padding: 10px 20px;
    margin-left: 0;           /* 间距统一交给 gap */
    border-radius: 30px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;      /* 修复“退出”被挤成竖排圆点 */
}

.auth-nav > span { white-space: nowrap; }

.btn-primary {
    background: #fff;
    color: #333;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.btn-outline {
    border: 2px solid rgba(255, 255, 255, 0.8) !important;
    /* 增强边框可见度 */
    color: #fff !important;
    /* 增强文字颜色 */
    background: transparent;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: #fff !important;
}

/* App Grid Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 80px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 40px;
    justify-items: center;
    position: relative;
}

/* Crystal App Icons */
.app-icon-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 120px;
    cursor: grab;
    transition: transform 0.2s ease, opacity 0.2s ease;
    position: relative;
}

.app-icon-wrapper:active {
    cursor: grabbing;
}

.app-icon-wrapper:hover {
    transform: translateY(-8px) scale(1.03);
}

.app-icon-wrapper.dragging {
    opacity: 0.4;
    transform: scale(0.9);
}

.app-icon {
    width: 90px;
    height: 90px;
    border-radius: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
    overflow: visible;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.1) 100%);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5), 0 10px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.app-icon img {
    -webkit-user-drag: none;
    user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.app-char {
    font-size: 36px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.app-name {
    font-size: 14px;
    color: #1a1a2e;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 1);
    text-align: center;
    line-height: 1.4;
    max-width: 110px;
    word-wrap: break-word;
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

/* Info Badge */
.info-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    color: #333;
    font-weight: bold;
    font-family: Georgia, serif;
    font-style: italic;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 10;
    font-size: 13px;
    transition: all 0.2s;
}

.info-badge:hover {
    transform: scale(1.15);
    background: #fff;
    color: #007bff;
}

/* Admin Specific */
.admin-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    max-width: 1200px;
    margin: 0 auto;
    gap: 20px;
    padding: 0 20px;
}

.admin-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.panel-title {
    margin-bottom: 20px;
    font-size: 18px;
    color: #555;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    padding-bottom: 10px;
}

/* Form Elements */
.glass-input {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 10px 15px;
    border-radius: 10px;
    outline: none;
    transition: all 0.3s;
    width: 100%;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.login-card {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 30px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

/* Tips Bar at Bottom (Static, not fixed) */
.tips-bar {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    color: #555;
}

.tips-bar p {
    margin: 0;
}

/* Icon color variants (fallback) */
.icon-blue {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
}

.icon-red {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.icon-green {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.icon-purple {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
}

.icon-pink {
    background: linear-gradient(135deg, #ffdde1 0%, #ee9ca7 100%);
}

.icon-default {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

/* Tooltip for description on hover */
.app-icon-wrapper[data-desc]:hover::after {
    content: attr(data-desc);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    animation: tooltipShow 0.3s ease 0.5s forwards;
}

@keyframes tooltipShow {
    to {
        opacity: 1;
        margin-top: 12px;
    }
}

/* ========== Mobile Responsive for Global Styles ========== */
@media screen and (max-width: 768px) {

    /* 三列网格在窄屏下让卡片服从列宽，避免固定 120px 把页面撑出横向滚动。 */
    .app-icon-wrapper {
        width: 100%;
        max-width: 120px;
    }

    /* Login Card */
    .login-card {
        margin: 20px;
        padding: 25px;
        max-width: 100%;
    }

    .login-card h2 {
        font-size: 20px;
    }

    /* Form Elements */
    .glass-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    /* Disable tooltip on touch devices */
    .app-icon-wrapper[data-desc]:hover::after {
        display: none;
    }

    /* Detail Popup */
    #detailPopup>div {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
}

/* App Expiration Styles */
.app-expired .app-icon {
    filter: grayscale(100%);
    opacity: 0.7;
}

.app-expired .app-name {
    color: #777;
}

/* Expiring visual cues */
.user-expiring {
    border: 2px solid #ff4d4f !important;
    background: #fff1f0 !important;
    color: #cf1322 !important;
    animation: pulse-border 2s infinite;
}

.app-expiring .app-icon {
    border: 2px solid #ff4d4f !important;
}

.app-expiring .info-badge {
    background: #ff4d4f !important;
    color: white !important;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(255, 77, 79, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 77, 79, 0);
    }
}

/* Profile Modal */
#profileModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.profile-card {
    background: #fff;
    width: 600px;
    max-width: 90%;
    border-radius: 20px;
    padding: 25px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.profile-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.profile-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.profile-content::-webkit-scrollbar {
    width: 6px;
}

.profile-content::-webkit-scrollbar-track {
    background: transparent;
}

.profile-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.profile-section {
    margin-bottom: 25px;
}

.profile-section h4 {
    margin-bottom: 15px;
    color: #1a1a2e;
    font-size: 16px;
    border-left: 4px solid #667eea;
    padding-left: 10px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.profile-item {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 10px;
}

.profile-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.profile-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.app-status-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.app-status-table th {
    text-align: left;
    padding: 12px;
    color: #666;
    border-bottom: 2px solid #eee;
}

.app-status-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    color: #444;
}

.status-tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

.st-valid {
    background: #e6fffa;
    color: #047857;
}

.st-expiring {
    background: #fff1f0;
    color: #cf1322;
}

.st-expired {
    background: #f3f4f6;
    color: #6b7280;
}

.st-pending {
    background: #fffaf0;
    color: #c05621;
}
