/* MEMORIES Admin Panel — Dark theme CSS */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1e2130;
    --bg-card-hover: #252838;
    --text-primary: #e2e4e9;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6080;
    --accent: #6366f1;
    --accent-hover: #7c7ff5;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #3b82f6;
    --border: #2d3148;
    --radius: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Auth pages layout --- */
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 0 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 32px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.auth-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* --- Authenticated layout --- */
body:not(.auth-page) {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    font-weight: 600;
}

.nav-links {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    margin-bottom: 4px;
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: white;
}

.nav-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.nav-user {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    margin-left: 240px;
}

/* --- Forms --- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font);
    transition: border-color 0.15s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
}

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

.otp-input {
    font-size: 24px !important;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 600;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* --- Alerts --- */
.alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* --- OTP Timer --- */
.otp-timer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

#timer-countdown {
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.3s;
}

/* --- Auth notes & links --- */
.auth-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 24px;
}

.auth-back-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}

.auth-back-link:hover {
    text-decoration: underline;
}

/* --- Page headers --- */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.back-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 12px;
}

.back-link:hover {
    text-decoration: underline;
}

/* --- Stats Grid (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-secondary {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* --- Dashboard sections --- */
.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.dashboard-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.dashboard-section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* --- Quick Links --- */
.quick-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.15s;
}

.quick-link:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.quick-link-icon {
    font-size: 24px;
}

.view-all-link {
    display: block;
    margin-top: 12px;
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
}

.view-all-link:hover {
    text-decoration: underline;
}

/* --- Data Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:hover {
    background: var(--bg-card);
}

.data-table.compact th,
.data-table.compact td {
    padding: 8px 12px;
}

.data-table code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.truncate {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Status Badges --- */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.severity-badge {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.severity-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.severity-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.severity-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* --- Entry Types --- */
.entry-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.entry-type.text {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.entry-type.voice {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.entry-type.photo {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

/* --- Filters Bar --- */
.filters-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
}

.filter-input,
.filter-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}

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

.filter-input {
    width: 200px;
}

.filter-small {
    width: 100px;
}

.filter-wide {
    flex: 1;
    min-width: 250px;
}

.filter-wide .filter-select {
    width: 100%;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: center;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
}

.page-link:hover {
    background: var(--bg-card-hover);
}

.page-link.current {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
}

/* --- Detail Pages --- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.detail-list {
    display: grid;
    gap: 12px;
}

.detail-list dt {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-list dd {
    font-size: 14px;
    color: var(--text-primary);
}

.detail-section {
    margin-top: 32px;
}

.detail-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Question rows --- */
.active-row {
    /* default styling */
}

.inactive-row {
    opacity: 0.6;
}

.inactive-row .question-text {
    text-decoration: line-through;
}

.editing-row {
    background: var(--bg-secondary);
}

.edit-form {
    padding: 12px;
}

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.input-small {
    width: 80px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.input-medium {
    width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.input-wide {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
}

textarea.input-wide {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* --- Settings --- */
.settings-category {
    margin-bottom: 32px;
}

.settings-category h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.setting-value {
    font-family: monospace;
    color: var(--text-secondary);
}

/* --- Logs --- */
.log-row {
    cursor: pointer;
}

.log-row:hover {
    background: var(--bg-card-hover);
}

.severity-row-warning {
    border-left: 3px solid var(--warning);
}

.severity-row-error {
    border-left: 3px solid var(--danger);
}

.log-detail-row td {
    padding: 0;
    background: var(--bg-secondary);
}

.log-details {
    padding: 16px;
}

.log-detail-row {
    margin-bottom: 12px;
}

.log-detail-row strong {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.log-details pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius);
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.error-text {
    color: var(--danger);
}

/* --- Timeline --- */
.user-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.user-summary span {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-summary strong {
    color: var(--text-primary);
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

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

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
}

.timeline-question {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

.timeline-content {
    color: var(--text-primary);
}

.timeline-text {
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 12px;
}

.timeline-transcription {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.audio-player {
    margin: 12px 0;
}

.audio-player audio {
    width: 100%;
    max-width: 400px;
    height: 40px;
}

.media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.photo-thumb {
    display: block;
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

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

/* --- Health --- */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.health-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.health-list dt {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.health-list dd {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-fill.warning {
    background: var(--warning);
}

.progress-fill.danger {
    background: var(--danger);
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.health-section {
    margin-bottom: 32px;
}

.health-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.page-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* --- Empty states --- */
.no-data {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 48px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
}

/* --- Utilities --- */
.text-muted {
    color: var(--text-muted);
}

a {
    color: var(--accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

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

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

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-input {
        width: 100%;
    }
}
