﻿/* ── Base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 16px;
    color: #1a1a2e;
    background-color: #f5f6fa;
    -webkit-font-smoothing: antialiased;
    /* iOS safe areas for notch/home indicator */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Ensure standalone PWA uses full viewport */
@media all and (display-mode: standalone) {
    html, body {
        min-height: 100vh;
        overflow-x: hidden;
    }
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
}

/* ── Layout ── */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.85rem;
}

    .top-bar button {
        background: none;
        border: 1px solid #d1d5db;
        padding: 0.35rem 0.75rem;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.8rem;
        color: #4b5563;
    }

        .top-bar button:hover {
            background: #f3f4f6;
        }

main {
    flex: 1;
}

.content {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ── Auth pages ── */
.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

    .auth-container h1 {
        text-align: center;
        font-size: 1.8rem;
        color: #1a56db;
        margin-bottom: 1.5rem;
    }

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
}

    .auth-tabs button {
        flex: 1;
        padding: 0.75rem;
        border: none;
        background: none;
        font-size: 1rem;
        font-weight: 500;
        color: #6b7280;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        margin-bottom: -2px;
        transition: all 0.2s;
    }

        .auth-tabs button.active {
            color: #1a56db;
            border-bottom-color: #1a56db;
        }

        .auth-tabs button:hover:not(.active) {
            color: #374151;
        }

/* ── Forms ── */
.auth-form,
.change-password-section,
.account-info,
.sign-out-section {
    background: #ffffff;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
}

.form-group {
    margin-bottom: 1rem;
}

    .form-group label {
        display: block;
        font-size: 0.85rem;
        font-weight: 600;
        color: #374151;
        margin-bottom: 0.35rem;
    }

    .form-group input {
        width: 100%;
        padding: 0.7rem 0.85rem;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 1rem;
        color: #1a1a2e;
        background: #f9fafb;
        transition: border-color 0.2s;
        -webkit-appearance: none;
    }

        .form-group input:focus {
            outline: none;
            border-color: #1a56db;
            background: #ffffff;
            box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
        }

        .form-group input:disabled {
            opacity: 0.6;
        }

/* ── Buttons ── */
.btn-primary {
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    background: #1a56db;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-appearance: none;
}

    .btn-primary:hover:not(:disabled) {
        background: #1544b5;
    }

    .btn-primary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-secondary {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #4b5563;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

    .btn-secondary:hover {
        background: #f3f4f6;
    }

/* ── Messages ── */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

.success-message {
    background: #f0fdf4;
    color: #16a34a;
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #bbf7d0;
}

.validation-errors {
    margin: 0.35rem 0 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    color: #dc2626;
}

    .validation-errors li::before {
        content: "• ";
    }

/* ── Account page ── */
.account-info p {
    margin: 0.4rem 0;
    font-size: 0.9rem;
}

.account-info strong {
    color: #374151;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

th, td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.85rem;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

td {
    border-bottom: 1px solid #f3f4f6;
}

tr:last-child td {
    border-bottom: none;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
    .content {
        padding: 0.75rem;
    }

    .auth-container {
        margin: 1rem auto;
    }

        .auth-container h1 {
            font-size: 1.5rem;
        }
}

/* ── Connection overlay ── */
.connection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f6fa;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.connection-message {
    text-align: center;
    padding: 2rem;
}

    .connection-message p {
        margin: 0.5rem 0;
        font-size: 1.2rem;
        font-weight: 600;
        color: #374151;
    }

.connection-detail {
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    color: #6b7280 !important;
}

.connection-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fef2f2;
    color: #dc2626;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    border: 2px solid #fecaca;
}

.connection-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #1a56db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Bottom Navigation Bar
   ======================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 1000;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #9e9e9e;
    font-size: 11px;
    gap: 4px;
    padding: 4px 8px;
    min-width: 64px;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

    .bottom-nav-item:hover {
        color: #6b6b6b;
        text-decoration: none;
    }

    .bottom-nav-item.active {
        color: #1976d2;
    }

.nav-icon {
    width: 26px;
    height: 26px;
}

.nav-label {
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
}

/* Prevent content from hiding behind bottom nav */
.content {
    padding-bottom: 80px;
}
