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

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222845;
    --border: #2a3050;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* ===== Animated Background ===== */
.bg-animated {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.12;
    animation: blobFloat 20s ease-in-out infinite;
}

[data-theme="light"] .bg-blob {
    opacity: 0.08;
}

.bg-blob:nth-child(1) {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    top: -200px;
    left: -100px;
    animation-duration: 22s;
}

.bg-blob:nth-child(2) {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    top: 50%;
    right: -150px;
    animation-duration: 18s;
    animation-delay: -5s;
}

.bg-blob:nth-child(3) {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #06b6d4, #6366f1);
    bottom: -100px;
    left: 30%;
    animation-duration: 25s;
    animation-delay: -10s;
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(60px, -40px) scale(1.1); }
    50% { transform: translate(-30px, 60px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.05); }
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 24px;
    position: relative;
    z-index: 1;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #e2e8f0 0%, #6366f1 50%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

[data-theme="light"] .hero-title {
    background: linear-gradient(135deg, #1e293b 0%, #6366f1 50%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.hero-line {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    margin: 20px auto 0;
    border-radius: 2px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: all 0.3s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(20deg);
}

/* ===== Search Bar ===== */
.search-wrap {
    margin-bottom: 24px;
    position: relative;
}

.search-wrap i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input:focus + i,
.search-wrap:focus-within i {
    color: var(--accent);
}

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

.no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 1rem;
    display: none;
}

/* ===== Category Filters ===== */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.category-filters:empty { display: none; }

.cat-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.cat-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ===== Card Category Badge ===== */
.card-cat {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Sites Grid (Public) ===== */
.sites-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.site-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.site-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.site-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 40px var(--accent-glow);
}

[data-theme="light"] .site-card:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.08), 0 0 40px var(--accent-glow);
}

.site-card:hover::before { opacity: 1; }

.site-card.hidden { display: none; }

.card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: transform 0.3s;
}

.site-card:hover .card-icon { transform: scale(1.1); }

.card-body { flex: 1; min-width: 0; }
.card-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.card-body p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: all 0.3s;
    flex-shrink: 0;
}
.site-card:hover .card-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

/* ===== Status Dots ===== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}
.status-up { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-down { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.status-unknown { background: var(--text-muted); }

/* ===== Thumbnail Cards ===== */
.site-card.has-thumb {
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.site-card.has-thumb .card-main {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    width: 100%;
}

.site-card:not(.has-thumb) .card-main {
    display: contents;
}

.card-thumb {
    width: 100%;
    height: 160px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.site-card:hover .card-thumb img {
    transform: scale(1.05);
}

/* ===== Uptime Bar (Admin) ===== */
.uptime-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.uptime-pct {
    font-weight: 600;
}

.uptime-pct.good { color: var(--success); }
.uptime-pct.warn { color: #f59e0b; }
.uptime-pct.bad { color: var(--danger); }

.uptime-mini {
    display: flex;
    gap: 2px;
    align-items: center;
}

.uptime-mini-bar {
    width: 4px;
    height: 16px;
    border-radius: 2px;
}

.uptime-mini-bar.up { background: var(--success); }
.uptime-mini-bar.down { background: var(--danger); }

/* ===== Uptime Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.modal h3 i { color: var(--accent); margin-right: 8px; }

.modal-close {
    float: right;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close:hover { color: var(--text-primary); }

.uptime-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.uptime-log-table th {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.uptime-log-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

/* ===== Thumbnail Preview (Admin) ===== */
.thumb-current {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.thumb-current img {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* ===== Visitor Counter ===== */
.visitor-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.visitor-count i { font-size: 0.75rem; }

.visitor-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    margin-top: 60px;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.footer-divider {
    width: 4px;
    height: 4px;
    background: var(--border);
    border-radius: 50%;
}

/* ===== Loading & Empty ===== */
.loading, .empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-size: 1rem;
}
.loading i { margin-right: 8px; }

/* ===== Login ===== */
.login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.4rem;
    color: var(--text-primary);
}
.login-form h2 i { color: var(--accent); margin-right: 8px; }

/* ===== Admin Layout ===== */
.admin-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.admin-header h1 i { color: var(--accent); margin-right: 8px; }

.admin-nav { display: flex; gap: 8px; }

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.panel h2 {
    font-size: 1.15rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}
.panel h2 i { color: var(--accent); margin-right: 8px; }

/* ===== Stats Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    margin-bottom: 0;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}
.hint a { color: var(--accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ===== Icon & Color Inputs ===== */
.icon-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
}
.icon-input-wrap i { font-size: 1.1rem; color: var(--accent); }
.icon-input-wrap input {
    border: none !important;
    background: transparent !important;
    padding-left: 0 !important;
    box-shadow: none !important;
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.color-input-wrap input[type="color"] {
    width: 44px;
    height: 40px;
    padding: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.color-input-wrap span {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Toggle Switch ===== */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}
.toggle-label input { display: none; }
.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}
.toggle-label input:checked + .toggle-switch { background: var(--accent); }
.toggle-label input:checked + .toggle-switch::after {
    left: 21px;
    background: white;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
    color: var(--text-primary);
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: #5558e6;
    box-shadow: 0 4px 15px rgba(99,102,241,0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ===== Sites List (Admin) ===== */
.sites-list { display: flex; flex-direction: column; gap: 8px; }

.site-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.site-row:hover { border-color: var(--accent); }
.site-row.inactive { opacity: 0.5; }

.site-row-icon { font-size: 1.2rem; width: 32px; text-align: center; }
.site-row-info { flex: 1; min-width: 0; }
.site-row-info strong { display: block; font-size: 0.95rem; }
.site-row-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.site-row-info .site-row-cat {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
    margin-top: 2px;
}
.site-row-info .site-row-notes {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Custom Icon Preview ===== */
.icon-preview-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

.file-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-input-wrap .btn { flex-shrink: 0; }

.icon-current {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.icon-current img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

/* ===== Scan Results ===== */
.scan-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.scan-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.scan-item.exists { opacity: 0.5; }
.scan-item label { flex: 1; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.scan-item .scan-type {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
}

/* ===== Category Manager ===== */
.cat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.cat-row-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-row-name { flex: 1; font-size: 0.9rem; }
.cat-row-count { font-size: 0.8rem; color: var(--text-muted); }

/* ===== Drag Handle ===== */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost {
    opacity: 0.3;
    border: 2px dashed var(--accent) !important;
}

.site-row-clicks {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.site-row-clicks i { margin-right: 4px; color: var(--accent); }

.site-row-actions { display: flex; gap: 4px; }

.badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge.active { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.inactive { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ===== Alert ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero-title { font-size: 2rem; }
    .site-card { padding: 18px; gap: 14px; }
    .site-card .card-cat { display: none; }
    .form-row { flex-direction: column; gap: 0; }
    .admin-header { flex-direction: column; gap: 12px; text-align: center; }
    .card-body p { white-space: normal; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .footer { flex-direction: column; gap: 8px; }
    .footer-divider { display: none; }
    .category-filters { justify-content: center; }
    .card-thumb { height: 120px; }
    .site-card.has-thumb .card-main { padding: 16px 18px; }
}
