/* ===== Stasfy — Minimal Dark Theme ===== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

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

:root {
    --bg: #0a0a0f;
    --bg-card: #13131a;
    --bg-input: #1a1a24;
    --bg-hover: #1e1e2a;
    --border: #2a2a3a;
    --text: #e4e4ed;
    --text-dim: #8888a0;
    --text-muted: #555568;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-h: 60px;
}

html {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
    overflow-x: hidden;
}

/* ===== Layout ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: var(--safe-top) 16px 0;
    height: calc(52px + var(--safe-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--accent);
}

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

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(52px + var(--safe-top) + 12px) 16px 16px;
    min-height: 100dvh;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    height: calc(var(--nav-h) + var(--safe-bottom));
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 16px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }

.nav-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ===== Typography ===== */
.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color var(--transition);
}

.card--important {
    border-left: 3px solid var(--warning);
}

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

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Avatar ===== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar--lg { width: 72px; height: 72px; font-size: 1.6rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.93rem;
    transition: border-color var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
}

.form-textarea { resize: vertical; min-height: 60px; }
.form-select { cursor: pointer; }

.char-count {
    text-align: right;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.char-count.warn { color: var(--warning); }
.char-count.over { color: var(--danger); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--text-dim); color: var(--text); }

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

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; }

/* ===== Toggle Switch ===== */
.toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.toggle + .toggle { border-top: 1px solid var(--border); }

.toggle-label { font-size: 0.9rem; }
.toggle-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.switch {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}

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

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 13px;
    cursor: pointer;
    transition: background var(--transition);
}

.switch-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.switch input:checked + .switch-slider { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); background: var(--accent); }

/* ===== Tags / Chips ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.chip--accent { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chip--warning { background: rgba(245,158,11,0.12); border-color: var(--warning); color: var(--warning); }

/* ===== Day Picker (recurring status) ===== */
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }

.day-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.day-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== Status Type Selector ===== */
.type-selector { display: flex; gap: 8px; margin-bottom: 16px; }

.type-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.type-btn.active {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

/* ===== User Row ===== */
.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.user-row + .user-row { border-top: 1px solid var(--border); }
.user-row .user-info { flex: 1; min-width: 0; }
.user-row .user-name { font-weight: 600; font-size: 0.9rem; }
.user-row .user-handle { font-size: 0.78rem; color: var(--text-muted); }

/* ===== Notification Row ===== */
.notif-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
}

.notif-row + .notif-row { border-top: 1px solid var(--border); }
.notif-row.unread { background: var(--accent-dim); margin: 0 -16px; padding: 12px 16px; border-radius: var(--radius-sm); }
.notif-body { flex: 1; }
.notif-text { font-size: 0.88rem; }
.notif-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.notif-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ===== FAB (Floating Action Button) ===== */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 90;
    transition: transform var(--transition), box-shadow var(--transition);
}

.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5); }
.fab svg { width: 24px; height: 24px; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.88rem; }

/* ===== Loading ===== */
.spinner {
    display: flex;
    justify-content: center;
    padding: 24px;
}

.spinner::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Auth Pages ===== */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80dvh;
    padding: 24px;
}

.auth-page .logo {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 4px;
    color: var(--accent);
}

.auth-page .tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.auth-form {
    width: 100%;
    max-width: 360px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.auth-footer a { color: var(--accent); text-decoration: none; }

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 12px;
}

/* ===== Profile Page ===== */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 0;
    margin-bottom: 16px;
}

.profile-header .display-name { font-size: 1.2rem; font-weight: 700; margin-top: 12px; }
.profile-header .username { font-size: 0.85rem; color: var(--text-muted); }

.photo-upload {
    position: relative;
    cursor: pointer;
}

.photo-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.photo-upload:hover .photo-upload-overlay { opacity: 1; }

/* ===== Modal / Sheet ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-sheet {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 20px 16px calc(20px + var(--safe-bottom));
    animation: slideUp 0.25s ease;
}

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

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Selection ===== */
::selection { background: var(--accent); color: #fff; }
