/* Custom overrides and additions to PatternFly */

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* Hours display emphasis */
.hours-display {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pf-v5-global--primary-color--100);
}

/* Component status badges */
.status-serviceable {
    --pf-v5-c-label--m-green--BackgroundColor: var(--pf-v5-global--success-color--100);
}

.status-due {
    --pf-v5-c-label--m-orange--BackgroundColor: var(--pf-v5-global--warning-color--100);
}

.status-overdue {
    --pf-v5-c-label--m-red--BackgroundColor: var(--pf-v5-global--danger-color--100);
}

/* Card styling */
.pf-v5-c-card {
    height: 100%;
}

.pf-v5-c-card__body dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.pf-v5-c-card__body dt {
    font-weight: 600;
}

.pf-v5-c-card__body dd {
    margin: 0;
}

/* Modal backdrop styling */
.pf-v5-c-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Gallery layout for cards */
.pf-l-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.pf-l-gallery.pf-m-gutter {
    gap: 1.5rem;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--pf-v5-global--primary-color--100);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Alert positioning */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .pf-l-gallery {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Document Grid and Viewer Styles
   ======================================== */

/* Document Grid */
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.document-item {
    cursor: pointer;
    border: 1px solid var(--pf-v5-global--BorderColor--100);
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    background: var(--pf-v5-global--BackgroundColor--100);
}

.document-item:hover {
    box-shadow: var(--pf-v5-global--BoxShadow--md);
    transform: translateY(-2px);
}

.document-thumbnail {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--pf-v5-global--BackgroundColor--200);
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.document-placeholder {
    color: var(--pf-v5-global--disabled-color--100);
    font-size: 3rem;
}

.document-info {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.document-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-type {
    font-size: 0.75rem;
    color: var(--pf-v5-global--Color--200);
}

/* Document Viewer Modal */
.document-viewer-modal {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.document-viewer-body {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.document-viewer-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.image-counter {
    font-size: 0.875rem;
    color: var(--pf-v5-global--Color--200);
}

.viewer-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 60vh;
}

.viewer-image {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    box-shadow: var(--pf-v5-global--BoxShadow--sm);
}

.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nav-button:hover {
    background: rgba(0, 0, 0, 0.7);
}

.nav-prev {
    left: 1rem;
}

.nav-next {
    right: 1rem;
}

.image-notes {
    font-size: 0.875rem;
    color: var(--pf-v5-global--Color--200);
    font-style: italic;
    text-align: center;
    max-width: 600px;
}

/* Thumbnail Strip */
.thumbnail-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem;
    max-width: 100%;
}

.thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
}

.thumbnail:hover {
    opacity: 0.8;
}

.thumbnail.active {
    border-color: var(--pf-v5-global--primary-color--100);
    opacity: 1;
}

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

/* Stack layout for logbook */
.pf-v5-l-stack {
    display: flex;
    flex-direction: column;
}

.pf-v5-l-stack.pf-m-gutter {
    gap: 1rem;
}

/* Responsive document grid */
@media (max-width: 576px) {
    .document-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-button {
        width: 32px;
        height: 32px;
    }

    .thumbnail {
        width: 50px;
        height: 66px;
    }
}

/* ========================================
   Airworthiness Status Styles
   ======================================== */

/* Card border colors for status */
.card-border-red {
    border-left: 4px solid var(--pf-v5-global--danger-color--100) !important;
}

.card-border-orange {
    border-left: 4px solid var(--pf-v5-global--warning-color--100) !important;
}

/* Airworthiness Badge */
.airworthiness-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    font-size: 0.875rem;
    font-weight: 600;
}

.airworthiness-green {
    background-color: var(--pf-v5-global--success-color--100);
    color: white;
}

.airworthiness-orange {
    background-color: var(--pf-v5-global--warning-color--100);
    color: var(--pf-v5-global--Color--dark-100);
}

.airworthiness-red {
    background-color: var(--pf-v5-global--danger-color--100);
    color: white;
}

.airworthiness-badge .status-icon {
    display: flex;
    align-items: center;
}

/* Issue Summary */
.issue-summary {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--pf-v5-global--BorderColor--100);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.issue-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.issue-count.issue-red {
    color: var(--pf-v5-global--danger-color--100);
}

.issue-count.issue-orange {
    color: var(--pf-v5-global--warning-color--200);
}

/* Airworthiness Issues List */
.airworthiness-issues {
    margin-top: 1rem;
}

.issue-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    background-color: var(--pf-v5-global--BackgroundColor--200);
}

.issue-item.issue-severity-red {
    border-left: 3px solid var(--pf-v5-global--danger-color--100);
}

.issue-item.issue-severity-orange {
    border-left: 3px solid var(--pf-v5-global--warning-color--100);
}

.issue-icon {
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.issue-icon.icon-red {
    color: var(--pf-v5-global--danger-color--100);
}

.issue-icon.icon-orange {
    color: var(--pf-v5-global--warning-color--200);
}

.issue-content {
    flex: 1;
}

.issue-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.issue-description {
    font-size: 0.875rem;
    color: var(--pf-v5-global--Color--200);
}

.issue-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--pf-v5-global--Color--200);
    margin-bottom: 0.25rem;
}

/* ========================================
   Squawk Card Styles
   ======================================== */

.squawk-card {
    transition: box-shadow 0.2s;
}

.squawk-card:hover {
    box-shadow: var(--pf-v5-global--BoxShadow--md);
}

.squawk-card .pf-v5-c-card__actions {
    display: flex;
    gap: 0.25rem;
}

.squawk-card .pf-v5-c-card__actions .pf-v5-c-button {
    transition: color 0.2s;
}

.squawk-card .pf-v5-c-card__actions .pf-v5-c-button:hover {
    color: var(--pf-v5-global--primary-color--100);
}

.squawk-card .pf-v5-c-card__actions .pf-m-success:hover {
    color: var(--pf-v5-global--success-color--100);
}

/* Breadcrumb styling */
.pf-v5-c-breadcrumb {
    margin-bottom: 0.5rem;
}

.pf-v5-c-breadcrumb__list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pf-v5-c-breadcrumb__item {
    display: flex;
    align-items: center;
}

.pf-v5-c-breadcrumb__item-divider {
    margin: 0 0.5rem;
    color: var(--pf-v5-global--Color--200);
}

.pf-v5-c-breadcrumb__link {
    color: var(--pf-v5-global--link--Color);
    text-decoration: none;
}

.pf-v5-c-breadcrumb__link:hover {
    text-decoration: underline;
}

.pf-v5-c-breadcrumb__link.pf-m-current {
    color: var(--pf-v5-global--Color--100);
}

/* Badge for tab counts */
.pf-v5-c-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 10rem;
    background-color: var(--pf-v5-global--BackgroundColor--200);
    color: var(--pf-v5-global--Color--100);
}

.pf-v5-c-badge.pf-m-unread {
    background-color: var(--pf-v5-global--primary-color--100);
    color: white;
}

/* ========================================
   Notes Styles
   ======================================== */

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.note-item {
    padding: 0.75rem;
    background-color: var(--pf-v5-global--BackgroundColor--200);
    border-radius: var(--pf-v5-global--BorderRadius--sm);
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    border-left: 3px solid var(--pf-v5-global--primary-color--100);
}

.note-item:hover {
    background-color: var(--pf-v5-global--BackgroundColor--100);
    box-shadow: var(--pf-v5-global--BoxShadow--sm);
}

.note-text {
    margin: 0 0 0.5rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.notes-list:not(.notes-list-full) .note-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-meta {
    font-size: 0.75rem;
    color: var(--pf-v5-global--Color--200);
}

.note-edited {
    font-style: italic;
    margin-left: 0.25rem;
}

.notes-list-full {
    max-height: 60vh;
    overflow-y: auto;
}

/* ========================================
   Component Hours Remaining Styles
   ======================================== */

.hours-overdue {
    color: var(--pf-v5-global--danger-color--100);
    font-weight: 700;
}

.hours-critical {
    color: var(--pf-v5-global--danger-color--200);
    font-weight: 600;
}

.hours-warning {
    color: var(--pf-v5-global--warning-color--200);
    font-weight: 500;
}
