@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-black: #050505;
    --bg-dark: #121214;
    --card-bg: #1c1c1e;
    --card-hover: #2c2c2e;
    --card-border: rgba(255, 255, 255, 0.08);
    --accent-blue: #3b82f6;
    --neon-green: #34d399;
    --neon-red: #f87171;
    --text-main: #ffffff;
    --text-dim: #a1a1aa;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-black);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
}

body.logged-out .main-app {
    display: none;
}

body.logged-in .login-overlay {
    display: none;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-black);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    width: 100%;
    max-width: 340px;
    padding: 40px 30px;
    border-radius: 28px;
    border: 1px solid var(--card-border);
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-box p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-error {
    color: var(--neon-red);
    font-size: 0.8rem;
    margin-top: 15px;
    min-height: 1.2rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    margin-bottom: 24px;
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
}

.checkbox-group input {
    display: none;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--card-border);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    background: var(--bg-black);
}

.checkbox-group input:checked+.custom-checkbox {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.custom-checkbox svg {
    width: 12px;
    height: 12px;
    color: white;
    transform: scale(0);
    transition: transform 0.2s;
}

.checkbox-group input:checked+.custom-checkbox svg {
    transform: scale(1);
}

.checkbox-group span {
    font-size: 0.85rem;
    color: var(--text-dim);
    cursor: pointer;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Loader */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-black);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Header & Top Bar */
header {
    margin-bottom: 20px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 16px;
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.profile-icon {
    width: 36px;
    height: 36px;
    background: var(--card-bg);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-blue);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: background 0.2s;
}

.profile-icon:hover {
    background: var(--card-hover);
}

.top-actions {
    display: flex;
    gap: 8px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 12px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.icon-btn.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

/* Search Container */
.search-container {
    margin-bottom: 16px;
}

.search-box {
    background: var(--card-bg);
    height: 44px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.search-icon {
    color: #52525b;
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-main);
    width: 100%;
    font-size: 1rem;
    outline: none;
}

.search-box input::placeholder {
    color: #52525b;
}

.status-badge {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    padding-bottom: 8px;
}

/* Site List & Cards */
.site-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
}

.card:active {
    transform: scale(0.98);
}

.card-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.card-icon.online {
    color: var(--neon-green);
}

.card-icon.offline {
    color: var(--neon-red);
}

.card-body {
    flex-grow: 1;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-label {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-dim);
    opacity: 0.8;
}

.card-timer {
    font-size: 0.8rem;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
    color: var(--accent-blue);
    display: none;
}

.card.expanded .card-timer {
    display: block;
}

.timer-offline {
    color: var(--neon-red);
}

/* Groups */
.group-section {
    margin-bottom: 30px;
}

.group-header {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-blue);
    padding-left: 10px;
}

.admin-only:not(.is-admin) {
    display: none !important;
}

/* Settings View */
.view-hidden {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.settings-container h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.mgmt-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mgmt-row {
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--card-border);
}

.mgmt-info b {
    display: block;
    font-size: 0.9rem;
}

.mgmt-info span {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.mgmt-actions {
    display: flex;
    gap: 6px;
}

.mgmt-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: none;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mgmt-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.mgmt-btn.del-btn {
    background: rgba(248, 113, 113, 0.1);
    color: var(--neon-red);
}

.mgmt-btn.del-btn:hover {
    background: rgba(248, 113, 113, 0.2);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 3000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-dark);
    width: 100%;
    max-width: 400px;
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--card-border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-black);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}



.primary-btn {
    width: 100%;
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

/* Responsive Grid on Desktop */
@media (min-width: 768px) {
    .container {
        max-width: 1000px;
    }

    .site-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
}