/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #2d3748;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    color: #1a365d;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
    color: #2b6cb0;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Page headers */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: #718096;
    font-size: 1rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #2b6cb0;
    color: white;
}

.btn-primary:hover {
    background: #2c5282;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.action-btn {
    background: #e2e8f0;
    border: 2px solid #a0aec0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.4rem 0.6rem;
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
    background: #cbd5e0;
    border-color: #718096;
    transform: scale(1.05);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Form elements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #4a5568;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filters .form-group {
    margin-bottom: 0;
    min-width: 180px;
}

/* Event type badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-ship {
    background: #bee3f8;
    color: #2c5282;
}

.badge-family {
    background: #c6f6d5;
    color: #276749;
}

.badge-world {
    background: #feebc8;
    color: #975a16;
}

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

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2b6cb0;
}

.stat-card .stat-label {
    color: #718096;
    font-size: 0.9rem;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #718096;
}

.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #2b6cb0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

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

/* Clickable rows */
.clickable-row {
    cursor: pointer;
}

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0.5rem 1rem;
    margin-bottom: 1.5rem;
}

.detail-grid dt {
    font-weight: 600;
    color: #4a5568;
}

.detail-grid dd {
    margin: 0;
}

/* Document list */
.document-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.document-list li {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

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

/* Blazor default styles */
h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3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5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Collapsible Menu Styles */
.menu-toggle-checkbox {
    display: none;
}

.menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: rgba(0,0,0,0.3);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
}

.menu-toggle:hover {
    background: rgba(0,0,0,0.5);
}

/* Show/hide arrows based on state */
.menu-toggle .arrow-show {
    display: none;
}

.menu-toggle .arrow-hide {
    display: inline;
}

/* When checkbox is checked (menu collapsed) */
.menu-toggle-checkbox:checked ~ .app-container .sidebar {
    transform: translateX(-250px);
}

.menu-toggle-checkbox:checked ~ .app-container .main-content {
    margin-left: 0;
}

.menu-toggle-checkbox:checked ~ .app-container .menu-toggle {
    background: #2c5282;
}

.menu-toggle-checkbox:checked ~ .app-container .menu-toggle:hover {
    background: #3182ce;
}

.menu-toggle-checkbox:checked ~ .app-container .menu-toggle .arrow-show {
    display: inline;
}

.menu-toggle-checkbox:checked ~ .app-container .menu-toggle .arrow-hide {
    display: none;
}

/* Voyage Map Port Markers */
.port-marker {
    background: transparent;
    border: none;
}

.port-marker-inner {
    background: #2b6cb0;
    border: 2px solid #1a365d;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.port-marker-inner:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    justify-content: center;
}

.pagination-info {
    color: #4a5568;
    font-size: 0.9rem;
}

/* Sidebar user display */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: white;
}

.logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    color: white;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* ============================================================
   Mobile / touch device overrides (@media pointer: coarse)
   ============================================================ */

/* Desktop-only thumbnail — hidden on mobile via class */
.thumb-small { }   /* desktop: visible (default) */
.thumb-large { display: none; }  /* desktop: hidden */

/* Carousel wrapper — arrows hidden on desktop */
.carousel-wrapper { position: relative; }
.carousel-arrow   { display: none; }

@media (pointer: coarse) {

    /* --- Read-only: hide edit controls --- */
    .timeline-actions { display: none !important; }
    .edit-panel        { display: none !important; }

    /* --- Home: hide View Details button --- */
    .view-details-btn { display: none !important; }

    /* --- Timeline: hide year-group headings --- */
    .year-marker { display: none !important; }

    /* --- Timeline: desktop thumbnail hidden; mobile thumbnail shown --- */
    .thumb-small { display: none !important; }
    .thumb-large {
        display: block !important;
        width: 100%;
        height: auto;
        border-radius: 6px;
        margin-top: 0.5rem;
    }

    /* Carousel for multiple document thumbnails */
    .thumb-carousel {
        display: flex !important;
        overflow-x: auto;
        gap: 0.5rem;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }
    .thumb-carousel .thumb-large {
        flex: 0 0 100%;
        scroll-snap-align: start;
    }

    /* --- Ships: single-column layout --- */
    .ships-grid { grid-template-columns: 1fr !important; }

    /* --- VoyageMap: hide Port Statistics panel --- */
    .port-stats-panel { display: none !important; }

    /* --- Filters: stack vertically, label on left, control on right --- */
    .filters { flex-direction: column; }
    .filters .form-group {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        min-width: unset;
    }
    .filters .form-group .form-label {
        min-width: 75px;
        margin-bottom: 0;
        flex-shrink: 0;
        font-size: 0.9rem;
    }

    /* --- Carousel scroll arrows --- */
    .carousel-arrow {
        display: flex;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
        font-size: 2.5rem;
        line-height: 1;
        color: white;
        text-shadow: 0 0 6px rgba(0,0,0,0.8);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.15s;
    }
    .carousel-left  { left: 0.25rem; }
    .carousel-right { right: 0.25rem; }

    /* --- DocumentViewer: hide toolbar chrome on mobile --- */
    .btn-acrobat,
    .btn-fullscreen,
    .btn-select-text,
    .document-title,
    .description-panel { display: none !important; }

    /* --- PDF viewer: hide thumbnail strip; tighten navigation bar --- */
    .thumbnail-strip { display: none !important; }
    .gallery-nav { padding: 0.35rem 0.75rem !important; }
}
