/* ======================================================
   Nothing-tab v2 - 样式
   响应式 + 暗色模式
   ====================================================== */

/* ---------- 变量 ---------- */
:root {
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #666;
    --text-tertiary: #999;
    --border: #e8e8e8;
    --primary: #6c5ce7;
    --primary-hover: #5a4bd1;
    --primary-light: #e8e5ff;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --max-width: 1200px;
    --header-height: 60px;
    --widget-gap: 16px;
}

.dark-mode {
    --bg: #0f0f1a;
    --card-bg: #1a1a2e;
    --text: #e0e0e0;
    --text-secondary: #aaa;
    --text-tertiary: #777;
    --border: #2a2a3e;
    --primary: #7c6cf0;
    --primary-hover: #9b8ff5;
    --primary-light: #2a1f5e;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ---------- 布局 ---------- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- 顶部搜索栏 ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    height: var(--header-height);
    gap: 12px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.header h1 {
    font-size: 1.2rem;
    white-space: nowrap;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 24px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
}

.search-box select {
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text);
    outline: none;
    cursor: pointer;
    min-width: 72px;
    appearance: auto;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-box button {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 8px 18px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
}

.search-box button:hover {
    background: var(--primary-hover);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- Widgets 行 ---------- */
.widgets-row {
    display: flex;
    gap: var(--widget-gap);
    padding: 20px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.widget-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    min-width: 180px;
}

/* 时钟 */
.widget-clock .time {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    color: var(--primary);
}

.widget-clock .date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 日历 */
.widget-calendar { min-width: 240px; }

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calendar-header .month {
    font-weight: 600;
    font-size: 0.9rem;
}

.calendar-nav {
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.calendar-nav:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    gap: 2px;
}

.cal-day, .cal-empty {
    padding: 4px 0;
    font-size: 0.8rem;
    border-radius: 4px;
}

.cal-day.cal-today {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

/* 天气 */
.widget-weather { min-width: 180px; }

.weather-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.weather-city {
    font-weight: 600;
    font-size: 0.9rem;
}

.weather-refresh {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    padding: 2px;
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.weather-icon {
    font-size: 1.8rem;
}

.weather-temp {
    font-size: 1.4rem;
    font-weight: 700;
}

.weather-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------- 同步状态 ---------- */
.sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sync-status {
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    font-size: 0.78rem;
    transition: background 0.2s;
}

.sync-status:hover {
    background: var(--primary-light);
}

.sync-detail {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-left: 4px;
}

/* ---------- 分组 ---------- */
.groups-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 40px;
}

.group {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.group-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-lucky {
    background: var(--primary-light);
    color: var(--primary);
}

.group-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.site-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: all 0.2s;
    font-size: 0.85rem;
    overflow: hidden;
}

.site-link:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.site-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.site-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-tip {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

/* ---------- 管理入口 ---------- */
.admin-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(108,92,231,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 50;
}

.admin-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(108,92,231,0.5);
}

/* ---------- 响应式 ---------- */

/* 平板 */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .search-box {
        order: 3;
        width: 100%;
        flex: none;
    }

    .widgets-row {
        flex-wrap: nowrap;
        padding: 12px 0;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .widget-card {
        min-width: 160px;
        scroll-snap-align: start;
        padding: 12px 14px;
    }

    .widget-clock .time {
        font-size: 1.5rem;
    }

    .group-links {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 6px;
    }

    .site-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .group {
        padding: 12px 14px;
    }

    .admin-fab {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
}

/* 手机 */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .group-links {
        grid-template-columns: repeat(2, 1fr);
    }

    .widget-card {
        min-width: 140px;
    }

    .widget-clock .time {
        font-size: 1.3rem;
    }
}

/* ---------- 动画 ---------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.group {
    animation: fadeInUp 0.4s ease both;
}

.group:nth-child(1) { animation-delay: 0.05s; }
.group:nth-child(2) { animation-delay: 0.1s; }
.group:nth-child(3) { animation-delay: 0.15s; }
.group:nth-child(4) { animation-delay: 0.2s; }
