/* LiFollow v0.2 - Modern Warm UI */

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-soft: rgba(99, 102, 241, 0.08);
    --secondary-color: #0ea5e9;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warm-tint: #faf8f5;

    --bg-light: #f7f5f2;
    --bg-white: #ffffff;
    --border-light: #e8e4df;
    --text-dark: #2d2a26;
    --text-muted: #7a756e;

    --spacing-xs: 0.2rem;
    --spacing-sm: 0.35rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1.1rem;
    --spacing-xl: 1.5rem;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============= LAYOUT ============= */

.app-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    height: 100vh;
    gap: 0;
}

.sidebar {
    background-color: var(--bg-white);
    border-right: 1px solid var(--border-light);
    padding: var(--spacing-lg) var(--spacing-lg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: var(--spacing-lg);
}

.logo {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 2px;
}
.logo-img {
    width: 100%;
    max-width: 160px;
    height: auto;
    display: block;
    object-fit: contain;
}

.tagline {
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-menu li {
    margin-bottom: 2px;
}

.nav-link {
    display: block;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 0.88rem;
    font-weight: 450;
}

.nav-link:hover {
    background-color: var(--primary-soft);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding-top: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.user-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.main-content {
    overflow-y: auto;
    background-color: var(--bg-light);
    padding: var(--spacing-lg);
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

/* ============= PAGES ============= */

.page-header {
    margin-bottom: var(--spacing-lg);
}

.page-header h1 {
    font-size: 1.6rem;
    margin-bottom: 2px;
    color: var(--text-dark);
    font-weight: 650;
    letter-spacing: -0.01em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(145deg, #4338ca 0%, #6366f1 40%, #818cf8 100%);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: var(--spacing-lg);
}

.login-box {
    background: var(--bg-white);
    border-radius: 16px;
    padding: var(--spacing-xl) var(--spacing-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-logo {
    display: block;
    width: 80%;
    max-width: 240px;
    height: auto;
    margin: 0 auto var(--spacing-sm) auto;
    object-fit: contain;
}
.login-title {
    font-size: 1.6rem;
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
    font-size: 0.85rem;
}

.login-form {
    margin-bottom: var(--spacing-md);
}

.login-footer {
    text-align: center;
    font-size: 0.875rem;
}

.login-footer code {
    background: var(--bg-light);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
}

/* Dashboard Page */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.dashboard-page .events-card {
    grid-column: 1 / -1;
}

/* ============= CARDS ============= */

.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border-light);
}

.card-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.05rem;
    color: var(--text-dark);
    font-weight: 600;
}

.card-content {
    padding: var(--spacing-md) var(--spacing-lg);
}

.journal-preview {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: var(--spacing-md);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.stat-item {
    text-align: center;
    padding: var(--spacing-sm) 0;
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Action Buttons */
.actions-card .card-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: var(--spacing-sm);
}

.action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--spacing-md);
    background: var(--bg-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.action-button:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.action-icon {
    font-size: 1.5rem;
}

.action-text {
    font-size: 0.78rem;
    font-weight: 500;
}

/* Events List */
.events-list {
    list-style: none;
}

.event-item {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: var(--spacing-md);
}

.event-item:last-child {
    border-bottom: none;
}

.event-time {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 50px;
    font-size: 0.85rem;
}

.event-details {
    flex: 1;
}

.event-text {
    margin-bottom: 2px;
}

.event-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Timeline */
.timeline-container {
    position: relative;
    padding-left: 3.5rem;
}

.timeline-item {
    position: relative;
    margin-bottom: var(--spacing-lg);
}

.timeline-dot {
    position: absolute;
    left: -var(--spacing-lg);
    top: var(--spacing-md);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
}

.timeline-time {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.85rem;
}

.timeline-body {
    background: var(--warm-tint);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.timeline-text {
    margin-bottom: 2px;
}

.timeline-meta {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    font-size: 0.8rem;
}

/* ============= FORMS ============= */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-dark);
    font-size: 0.85rem;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: var(--bg-white);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
    resize: vertical;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

/* ============= BUTTONS ============= */

.btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    letter-spacing: 0.01em;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-large {
    padding: 8px 20px;
    font-size: 0.95rem;
}

.btn-logout {
    width: 100%;
    background: var(--danger-color);
    color: white;
}

.btn-logout:hover {
    background: #dc2626;
}

/* ============= BADGES ============= */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-source {
    background: var(--bg-light);
    color: var(--text-dark);
}

.badge-confidence {
    background: var(--secondary-color);
    color: white;
}

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

.date-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}

/* ============= ALERTS ============= */

.alert {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.88rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #7f1d1d;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #0c2d6b;
    border: 1px solid #93c5fd;
}

/* ============= UTILITY ============= */

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

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

.text-center {
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-muted);
    font-size: 0.88rem;
}

.info-box {
    background: #f0ecf9;
    border-left: 3px solid var(--primary-color);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.88rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.88rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: var(--spacing-md) 0;
}

.save-button-container {
    text-align: center;
}

/* ============= QUICK NAV ============= */

.quick-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
}

.quick-nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.quick-nav-links a {
    color: var(--primary-color);
    text-decoration: none;
}

.quick-nav-links a:hover {
    text-decoration: underline;
}

.quick-sep {
    color: var(--text-muted);
}

.quick-current {
    color: var(--text-dark);
    font-weight: 500;
}

.quick-nav-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.quick-capture-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
}

/* ============= NOTIFICATIONS ============= */

.notif-wrapper {
    position: relative;
}

.notif-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.15s;
}

.notif-btn:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    padding: 0 3px;
}

.notif-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.notif-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.notif-mark-all {
    font-size: 0.78rem;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.notif-mark-all:hover {
    text-decoration: underline;
}

.notif-list {
    overflow-y: auto;
    max-height: 360px;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.notif-item:hover {
    background: var(--bg-light);
}

.notif-item.unread {
    background: #f0f4ff;
}

.notif-item .notif-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    background: var(--bg-light);
}

.notif-item .notif-body {
    flex: 1;
    min-width: 0;
}

.notif-item .notif-title {
    font-weight: 500;
    line-height: 1.3;
}

.notif-item .notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.notif-item .notif-snippet {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.notif-empty {
    padding: 24px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============= FOOTER ============= */

.app-footer {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    max-width: 1200px;
    margin: 0 auto;
}

.footer-left, .footer-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.footer-brand {
    font-weight: 600;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.footer-icon {
    height: 18px;
    width: 18px;
    object-fit: contain;
}

.footer-sep {
    color: var(--border-light);
}

.footer-tech {
    color: var(--text-muted);
}

.footer-copy {
    color: var(--text-muted);
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
}

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

/* ============= HELP PAGE ============= */

.help-section {
    margin-bottom: var(--spacing-lg);
}

.help-section h2 {
    font-size: 1.15rem;
    margin-bottom: var(--spacing-sm);
    color: var(--primary-color);
}

.help-section h3 {
    font-size: 0.95rem;
    margin-bottom: var(--spacing-xs);
    margin-top: var(--spacing-md);
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-md);
}

.help-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.help-card h3 {
    margin-top: 0;
    margin-bottom: 3px;
    font-size: 0.92rem;
}

.help-card p {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin: 0;
}

.shortcut-list {
    list-style: none;
    padding: 0;
}

.shortcut-list li {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.shortcut-list li:last-child {
    border-bottom: none;
}

.shortcut-key {
    background: var(--bg-light);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border-light);
}

.faq-item {
    margin-bottom: var(--spacing-lg);
}

.faq-item summary {
    font-weight: 600;
    cursor: pointer;
    padding: var(--spacing-sm) 0;
    color: var(--text-dark);
}

.faq-item p {
    padding: var(--spacing-sm) 0 0 var(--spacing-md);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ============= DARK MODE ============= */

[data-theme="dark"] {
    --primary-color: #a5b4fc;
    --primary-dark: #818cf8;
    --primary-soft: rgba(165, 180, 252, 0.1);
    --secondary-color: #38bdf8;
    --accent-color: #fbbf24;
    --danger-color: #f87171;
    --success-color: #34d399;
    --warm-tint: #1e1d1a;

    --bg-light: #141310;
    --bg-white: #1e1c19;
    --border-light: #33302a;
    --text-dark: #ebe7e0;
    --text-muted: #9a9589;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] html,
[data-theme="dark"] body {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

[data-theme="dark"] .login-page {
    background: linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #3730a3 100%);
}

[data-theme="dark"] .alert-success {
    background: #064e3b;
    color: #a7f3d0;
    border-color: #059669;
}

[data-theme="dark"] .alert-error {
    background: #7f1d1d;
    color: #fecaca;
    border-color: #dc2626;
}

[data-theme="dark"] .alert-info {
    background: #1e3a5f;
    color: #bfdbfe;
    border-color: #3b82f6;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #28261f;
    color: var(--text-dark);
    border-color: #3d3930;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.12);
}

[data-theme="dark"] .notif-item.unread {
    background: #252319;
}

[data-theme="dark"] .info-box {
    background: #1f1d2e;
}

[data-theme="dark"] .reflow-menu {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .reflow-option:hover {
    background: #374151;
}

[data-theme="dark"] .badge-flow-pending {
    background: #422006;
    color: #fcd34d;
}

[data-theme="dark"] .badge-flow-confirmed {
    background: #064e3b;
    color: #6ee7b7;
}

/* ============= ADDITIONAL LAYOUT ============= */

.quick-nav-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 4px 10px;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.hide-mobile { }

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

#toast-container > * {
    pointer-events: auto;
}

@media (max-width: 768px) {
    .sidebar-close { display: flex; }
    .hide-mobile { display: none !important; }
    #toast-container { left: var(--spacing-md); right: var(--spacing-md); bottom: var(--spacing-md); }
}

/* ============= ANIMATIONS ============= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.fade-in { animation: fadeIn 0.3s ease-out; }
.fade-out { animation: fadeOut 0.3s ease-out forwards; }
.slide-in-right { animation: slideInRight 0.3s ease-out; }
.slide-in-left { animation: slideInLeft 0.3s ease-out; }

/* Progress / loading indicators */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

.skeleton {
    background: linear-gradient(90deg, var(--bg-light) 25%, var(--border-light) 50%, var(--bg-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
    min-height: 1em;
}

.progress-bar {
    height: 4px;
    background: var(--bg-light);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.progress-bar-indeterminate .progress-bar-fill {
    width: 40%;
    animation: shimmer 1.5s infinite;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px 20px;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    font-size: 0.9rem;
}
.toast-success { border-left: 4px solid var(--success-color); }
.toast-error { border-left: 4px solid var(--danger-color); }
.toast-info { border-left: 4px solid var(--primary-color); }

/* Card loading overlay */
.card-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}
.card-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Transition helpers */
.transition-all { transition: all 0.3s ease; }
.transition-opacity { transition: opacity 0.3s ease; }

/* ============= HAMBURGER MENU ============= */

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
    color: var(--text-dark);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1100;
    transition: all 0.2s ease;
}

.hamburger:hover {
    background: var(--bg-light);
}

.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: all 0.3s ease;
    position: relative;
}

.hamburger-line::before,
.hamburger-line::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
}

.hamburger-line::before {
    top: -6px;
}

.hamburger-line::after {
    top: 6px;
}

/* Hamburger active state (X shape) */
.hamburger.active .hamburger-line {
    background: transparent;
}

.hamburger.active .hamburger-line::before {
    top: 0;
    transform: rotate(45deg);
}

.hamburger.active .hamburger-line::after {
    top: 0;
    transform: rotate(-45deg);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============= RESPONSIVE ============= */

/* ---- Large tablets & small desktops (1024px) ---- */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 220px 1fr;
    }

    .main-content {
        padding: var(--spacing-lg);
    }

    .content-wrapper {
        max-width: 100%;
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }

    .help-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* ---- Tablets (768px) ---- */
@media (max-width: 768px) {
    /* Show hamburger, hide sidebar by default */
    .hamburger {
        display: flex;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    /* Mobile top bar: logo + hamburger */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--spacing-md) var(--spacing-lg);
        background: var(--bg-white);
        border-bottom: 1px solid var(--border-light);
        position: sticky;
        top: 0;
        z-index: 1050;
    }

    /* Sidebar becomes slide-out overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        flex-direction: column;
        padding: var(--spacing-lg);
        border-right: 1px solid var(--border-light);
        border-bottom: none;
        overflow-y: auto;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        margin-bottom: var(--spacing-xl);
        margin-right: 0;
    }

    .nav-menu {
        display: flex;
        flex-direction: column;
        gap: 0;
        flex: 1;
    }

    .nav-menu li {
        margin-bottom: var(--spacing-sm);
    }

    .nav-link {
        padding: var(--spacing-md);
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .sidebar-footer {
        border-top: 1px solid var(--border-light);
        border-left: none;
        padding-top: var(--spacing-lg);
        padding-left: 0;
        margin-top: auto;
    }

    .btn-logout {
        min-height: 44px;
    }

    /* Main content */
    .main-content {
        grid-column: 1;
        grid-row: 2;
        padding: var(--spacing-lg);
        min-height: 0;
    }

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

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

    /* Journal controls stack */
    .journal-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    /* Forms: stack all flex-row form groups */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Quick nav: allow wrapping */
    .quick-nav {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }

    .quick-nav-links {
        flex-wrap: wrap;
    }

    .quick-nav-actions {
        flex-wrap: wrap;
    }

    /* Notification panel */
    .notif-panel {
        width: 300px;
        right: -40px;
    }

    /* Footer stacks */
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-md);
    }

    .footer-left, .footer-right {
        justify-content: center;
    }

    /* Page header */
    .page-header h1 {
        font-size: 1.75rem;
    }

    /* Help grid */
    .help-grid {
        grid-template-columns: 1fr;
    }

    /* Toast repositioned for tablet */
    .toast {
        right: 16px;
        bottom: 16px;
        max-width: 320px;
    }
}

/* ---- Mobile phones (480px and below) ---- */
@media (max-width: 480px) {
    html, body {
        font-size: 15px;
        -webkit-text-size-adjust: 100%;
    }

    /* Sidebar narrower on small phones */
    .sidebar {
        width: 260px;
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .mobile-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    /* Main content: minimal padding */
    .main-content {
        padding: var(--spacing-md);
    }

    /* Page header */
    .page-header {
        margin-bottom: var(--spacing-lg);
    }

    .page-header h1 {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    /* Cards: full-bleed (no horizontal margin/border-radius) */
    .card {
        border-radius: 0;
        margin-left: calc(-1 * var(--spacing-md));
        margin-right: calc(-1 * var(--spacing-md));
        box-shadow: none;
        border-bottom: 1px solid var(--border-light);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .card-header h2 {
        font-size: 1.1rem;
        margin-bottom: 0;
    }

    .card-content {
        padding: var(--spacing-md);
    }

    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    /* Stats: keep 3-col but compact */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-sm);
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Action buttons: 2-col grid on mobile */
    .actions-card .card-content {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .action-button {
        padding: var(--spacing-md);
        min-height: 44px;
    }

    .action-icon {
        font-size: 1.5rem;
    }

    .action-text {
        font-size: 0.8rem;
    }

    /* Events list */
    .event-item {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .event-time {
        min-width: auto;
        font-size: 0.85rem;
    }

    .event-meta {
        font-size: 0.8rem;
    }

    /* Timeline: reduce left padding */
    .timeline-container {
        padding-left: var(--spacing-lg);
    }

    .timeline-item {
        margin-bottom: var(--spacing-lg);
    }

    .timeline-body {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .timeline-meta {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .timeline-time {
        font-size: 0.85rem;
    }

    .timeline-text {
        font-size: 0.9rem;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .form-group {
        margin-bottom: var(--spacing-md);
    }

    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 10px var(--spacing-md);
        min-height: 44px;
    }

    /* Buttons: touch-friendly sizing */
    .btn {
        min-height: 44px;
        padding: 10px var(--spacing-lg);
        font-size: 0.95rem;
    }

    .btn-small {
        min-height: 36px;
        padding: 6px var(--spacing-md);
        font-size: 0.85rem;
    }

    .btn-large {
        min-height: 48px;
        padding: 12px var(--spacing-xl);
        font-size: 1rem;
    }

    /* Quick nav: stack on very small screens */
    .quick-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) 0;
    }

    .quick-nav-links {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        font-size: 0.8rem;
    }

    .quick-nav-actions {
        width: 100%;
        justify-content: flex-start;
        gap: var(--spacing-sm);
    }

    .quick-capture-btn {
        min-height: 36px;
        padding: 6px 12px;
    }

    /* Notification panel: full-width */
    .notif-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        z-index: 1100;
    }

    .notif-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .date-badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    /* Login page */
    .login-container {
        padding: var(--spacing-md);
    }

    .login-box {
        padding: var(--spacing-lg);
    }

    .login-title {
        font-size: 1.5rem;
    }

    /* Alerts */
    .alert {
        padding: var(--spacing-md);
        font-size: 0.9rem;
        border-radius: var(--radius-sm);
    }

    /* Info box */
    .info-box {
        padding: var(--spacing-md);
        font-size: 0.9rem;
    }

    /* Help page */
    .help-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .help-card {
        padding: var(--spacing-md);
    }

    .help-section h2 {
        font-size: 1.15rem;
    }

    .help-section h3 {
        font-size: 0.95rem;
    }

    .shortcut-list li {
        flex-direction: column;
        gap: var(--spacing-xs);
        padding: var(--spacing-sm) 0;
    }

    .shortcut-key {
        align-self: flex-start;
    }

    /* FAQ items */
    .faq-item summary {
        padding: var(--spacing-md) 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Journal preview */
    .journal-preview {
        font-size: 0.9rem;
    }

    /* Footer */
    .app-footer {
        padding: var(--spacing-md) 0;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
        padding: 0 var(--spacing-md);
    }

    .footer-left, .footer-right {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .footer-sep {
        display: none;
    }

    /* Checkbox groups: larger touch targets */
    .checkbox-group label {
        min-height: 44px;
        padding: var(--spacing-sm) 0;
    }

    .checkbox-group input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* Toast: full-width at bottom */
    .toast {
        left: var(--spacing-md);
        right: var(--spacing-md);
        bottom: var(--spacing-md);
        max-width: none;
    }

    /* Save button container */
    .save-button-container {
        position: sticky;
        bottom: 0;
        background: var(--bg-white);
        padding: var(--spacing-md);
        margin: 0 calc(-1 * var(--spacing-md));
        border-top: 1px solid var(--border-light);
        z-index: 50;
    }

    .save-button-container .btn {
        width: 100%;
    }

    /* Empty state */
    .empty-state {
        padding: var(--spacing-lg);
        font-size: 0.9rem;
    }
}

/* ---- Very small phones (360px and below) ---- */
@media (max-width: 360px) {
    html, body {
        font-size: 14px;
    }

    .main-content {
        padding: var(--spacing-sm);
    }

    /* Cards: tighter padding */
    .card {
        margin-left: calc(-1 * var(--spacing-sm));
        margin-right: calc(-1 * var(--spacing-sm));
    }

    .card-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .card-content {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    /* Action buttons: single column */
    .actions-card .card-content {
        grid-template-columns: 1fr;
    }

    /* Stats: stack on very small */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }

    .stat-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: var(--spacing-xs) 0;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    /* Logo */
    .logo {
        font-size: 1.1rem;
    }

    .sidebar {
        width: 240px;
    }

    /* Quick nav: hide separators */
    .quick-sep {
        display: none;
    }

    .quick-nav-links a {
        padding: 2px 4px;
    }
}

/* ---- Capture tabs: horizontal scroll on mobile ---- */
@media (max-width: 600px) {
    .capture-tabs,
    .tab-nav,
    .tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: var(--spacing-sm);
        padding-bottom: var(--spacing-xs);
        white-space: nowrap;
    }

    .capture-tabs::-webkit-scrollbar,
    .tab-nav::-webkit-scrollbar,
    .tabs::-webkit-scrollbar {
        display: none;
    }

    .capture-tabs > *,
    .tab-nav > *,
    .tabs > * {
        flex-shrink: 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ---- Flex row stacking on mobile ---- */
@media (max-width: 600px) {
    /* Any inline flex pairs with gap should stack */
    .flex-row,
    .inline-group,
    .button-group,
    .filter-bar,
    .date-range,
    .journal-controls,
    .journal-actions,
    .settings-section-header,
    .integration-card-header,
    .integration-card-actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .filter-bar > *,
    .date-range > *,
    .button-group > * {
        width: 100%;
    }

    /* Make select inputs full width */
    .journal-controls select,
    .filter-bar select,
    .date-range input {
        width: 100%;
    }
}

/* ---- Landscape phones ---- */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .login-page {
        padding: var(--spacing-md);
    }

    .login-box {
        padding: var(--spacing-lg);
    }

    /* Notification panel: side panel in landscape */
    .notif-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        left: auto;
        width: 320px;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ---- Print styles ---- */
@media print {
    .sidebar,
    .hamburger,
    .sidebar-overlay,
    .mobile-header,
    .quick-nav,
    .notif-wrapper,
    .btn,
    .app-footer,
    .toast {
        display: none !important;
    }

    .app-container {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}

/* ---- Accessibility: reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .sidebar {
        transition: none;
    }

    .sidebar-overlay {
        transition: none;
    }
}

/* ---- Safe area insets for notched devices ---- */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-header {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }

    .main-content {
        padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
    }

    .toast {
        bottom: max(24px, env(safe-area-inset-bottom));
    }

    .save-button-container {
        padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
    }

    .notif-panel {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
