/* ===================================
   Global Styles & Reset
   =================================== */

/*
 * Centralized Stylesheet for Treadcrumbs
 *
 * This stylesheet consolidates all CSS from across the application
 * to provide consistent styling and reduce duplication.
 *
 * To use: <link rel="stylesheet" href="/assets/css/styles.css">
 */

:root {
    --max-inline-size-container: 48rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

[data-layout="cluster"] {
    display: flex;
    flex-wrap: wrap;
    gap: 2ch;
}

/* ===================================
   Accessibility
   =================================== */

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Focus indicators */
*:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Ensure buttons and links have visible focus */
button:focus-visible,
a:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===================================
   Typography
   =================================== */
h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 28px;
}

h2 {
    color: #333;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 18px;
}

/* ===================================
   Layout Containers
   =================================== */
.page-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
}

.container {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

    > .content {
        max-inline-size: var(--max-inline-size-container);
        margin-inline: auto;
    }
}

.wide-container {
    max-width: 1200px;
}

/* Bootstrap/Landing page specific */
.bootstrap-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 500px;
    width: 100%;
}

.landing-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ===================================
   Navigation
   =================================== */
nav {
    background-color: #333;
    padding: 15px 30px;

    > .content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        max-inline-size: var(--max-inline-size-container);
        margin-inline: auto;
    }
}

nav a {
    color: white;
    text-decoration: none;
    /* padding: 10px 15px; */
}

nav a:hover {
    background-color: #555;
    border-radius: 4px;
}

.nav-left {
    display: flex;
    gap: 20px;
}

.nav-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-item {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-item:hover {
    background-color: #555;
}

.nav-user {
    color: #e5e5e5;
    font-size: 0.9em;
}

/* ===================================
   Forms
   =================================== */

input[readonly],
input[disabled] {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

.admin-checkbox {
    margin-bottom: 20px;
}

.admin-checkbox input[type="checkbox"] {
    margin-right: 8px;
}

.admin-checkbox label {
    display: inline;
    font-weight: bold;
    color: #555;
}

.checkbox-group {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
}

/* Fieldset styling for accessibility */
fieldset {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

fieldset legend {
    font-weight: 500;
    color: #333;
    padding: 0 8px;
}

fieldset.checkbox-group {
    max-height: 200px;
    overflow-y: auto;
}

/* Disabled input styling */
input[readonly],
input[disabled],
.input-disabled {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

/* Current session badge */
.badge-current-session {
    background-color: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75em;
    margin-left: 8px;
}

/* Passkey remove form */
.passkey-remove-form {
    margin: 0;
}

/* User delete form */
.user-delete-form {
    margin: 0;
}

/* Invitation revoke form */
.invitation-revoke-form {
    margin: 0;
}

/* ===================================
   Messages & Alerts
   =================================== */
.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 13px;
    border: 1px solid #ffeaa7;
}

.warning strong {
    display: block;
    margin-bottom: 5px;
}

/* ===================================
   Links
   =================================== */
a {
    color: #005a87;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #667eea;
    text-decoration: none;
    font-size: 0.95em;
}

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

/* ===================================
   Tables
   =================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background-color: #f5f5f5;
    font-weight: bold;
    color: #333;
}

table tr:hover {
    background-color: #f9f9f9;
}

/* ===================================
   Cards & Boxes
   =================================== */
.invitation-box {
    background-color: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.passkey-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.passkey-info {
    flex: 1;
}

.passkey-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
}

.passkey-date {
    color: #666;
    font-size: 0.9em;
    margin: 3px 0;
}

.passkey-id {
    color: #666;
    font-size: 0.8em;
    margin-top: 3px;
    font-family: monospace;
}

.no-passkeys,
.no-trips {
    font-style: italic;
    color: #999;
    padding: 20px;
    text-align: center;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.user-card {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: box-shadow 0.3s;
}

.user-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-email {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.user-name {
    color: #666;
    margin-bottom: 10px;
}

/* ===================================
   Badges & Labels
   =================================== */
.admin-badge {
    background-color: #28a745;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    display: inline-block;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

/* ===================================
   Utility Classes
   =================================== */
code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
}

pre {
    background: #f8f8f8;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
}

small {
    display: block;
    margin-top: 5px;
    color: #666;
}

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

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ===================================
   Landing Page Specific
   =================================== */
.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.hero p {
    color: #666;
    font-size: 1.1em;
}

.sign-in-form {
    max-width: 400px;
    margin: 0 auto;
}

/* ===================================
   Email Template Styles
   (Used in invitation.php)
   =================================== */
.email-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.email-header {
    background-color: #007cba;
    color: white;
    padding: 20px;
    text-align: center;
}

.email-content {
    padding: 30px 20px;
    background-color: #f9f9f9;
}

.email-button {
    display: inline-block;
    padding: 12px 30px;
    background-color: #007cba;
    color: white !important;
    text-decoration: none;
    border-radius: 5px;
    margin: 20px 0;
}

.email-footer {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .page-container {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    nav {
        flex-direction: column;
        gap: 10px;
    }

    .nav-left,
    .nav-right {
        flex-direction: column;
        gap: 10px;
    }

    table {
        font-size: 14px;
    }

    .passkey-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===================================
   Page-Specific Styles
   =================================== */

/* Account Page */
.info-section {
    margin-bottom: 20px;
}

.info-label {
    font-weight: bold;
    color: #555;
    margin-bottom: 5px;
}

.info-value {
    color: #333;
    font-size: 1.1em;
}

.passkey-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

/* Landing/Index Page */
.page-landing .page-container {
    max-width: 500px;
    margin: 100px auto;
}

.page-landing h1 {
    color: #007cba;
    margin-bottom: 10px;
}

.page-home .page-container {
    max-width: 800px;
    margin: 20px auto;
}

.page-home h1 {
    color: #007cba;
    margin-bottom: 30px;
}

.user-info {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 30px;
}

.user-info strong {
    color: #007cba;
}

.section {
    margin-bottom: 30px;
}

.section h2 {
    color: #333;
    margin-bottom: 15px;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

#status {
    margin-top: 15px;
    font-style: italic;
    color: #666;
    min-height: 20px;
}

.links {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.logout {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.btn-logout {
    background-color: #dc3545;
    width: auto;
    padding: 10px 20px;
}

.btn-logout:hover {
    background-color: #c82333;
}

/* Passkey Register Page */
.page-passkey-register h1 {
    text-align: center;
}

.page-passkey-register #passkey-status {
    margin-top: 10px;
    font-style: italic;
    color: #666;
}

/* Trip Page */
.page-trip .container {
    text-align: center;
}

.trip-title {
    color: #007cba;
    font-size: 2.5em;
    margin-bottom: 30px;
}

.trip-id {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 20px;
    font-family: monospace;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    display: inline-block;
}

.trip-nav {
    display: flex;
    gap: 15px;
    margin: 30px 0;
    justify-content: center;
}

.trip-nav-link {
    padding: 12px 24px;
    background-color: #005a87;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.trip-nav-link:hover {
    background-color: #004466;
    text-decoration: none;
}

.trip-nav-link:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.sheet-data {
    text-align: left;
    margin-top: 40px;
}

.sheet-data h2 {
    margin-top: 0;
}

.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

.cache-info {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 20px;
}

.error-404 {
    color: #dc3545;
    font-size: 3em;
    margin-bottom: 20px;
}

.error-message {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 30px;
}

/* Admin Users Index Page */
.page-admin-users .container {
    max-width: 1000px;
}

.page-admin-users .user-card {
    position: relative;
}

.page-admin-users .user-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #007cba;
}

.page-admin-users .user-info {
    color: #666;
    font-size: 0.95em;
    line-height: 1.6;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
}

.badge-admin {
    background-color: #ff6b6b;
    color: white;
}

.badge-user {
    background-color: #4ecdc4;
    color: white;
}

.badge-current {
    background-color: #95a5a6;
    color: white;
    margin-left: 10px;
}

.trip-list, .passkey-list {
    margin-top: 5px;
}

.trip-item {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

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

.no-data {
    font-style: italic;
    color: #999;
}

/* Admin Users Invite Page */
.page-invite-user .checkbox-group {
    background-color: #fafafa;
}

.page-invite-user .checkbox-group label {
    font-weight: normal;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.page-invite-user .admin-checkbox {
    display: flex;
    align-items: center;
}
