/* ===========================
   PREMIUM FULLSCREEN SPECIES MODAL
   =========================== */
dialog#species-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    overflow: hidden;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

dialog#species-modal[open] {
    display: flex;
}

dialog#species-modal::backdrop {
    background-color: rgba(10, 12, 11, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] dialog#species-modal::backdrop {
    background-color: rgba(245, 245, 245, 0.85);
}

.modal-content {
    position: relative;
    width: 92vw;
    height: 90vh;
    max-width: 1300px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid color-mix(in srgb, var(--text-subtle) 15%, transparent);
    animation: modalScaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity;
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(18, 18, 18, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F4F4F4;
    font-size: 1.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    transition: all var(--transition-smooth);
}

[data-theme="light"] .modal-close {
    background: rgba(250, 250, 250, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #2C3539;
}

.modal-close:hover {
    color: var(--accent);
    transform: scale(1.1) rotate(90deg);
}

.modal-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
}

/* Single Column Image Gallery */
.modal-image-container {
    position: relative;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    min-height: 200px;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease, opacity 0.3s ease;
    user-select: none;
}

.modal-image-container img.zoomed {
    cursor: zoom-out;
    transform: scale(1.5);
}

.modal-image-container img:not(.zoomed) {
    cursor: zoom-in;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(18, 18, 18, 0.4);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F4F4F4;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    z-index: 10;
}

.gallery-nav:hover {
    background: var(--accent);
    color: var(--bg-primary);
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav.prev {
    left: 20px;
}

.gallery-nav.next {
    right: 20px;
}

.modal-thumbnails {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(18, 18, 18, 0.4);
    overflow-x: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    scroll-behavior: smooth;
}

/* Custom Scrollbar for thumbnails */
.modal-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.modal-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.modal-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.thumb-item {
    width: 60px;
    height: 45px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-smooth);
    opacity: 0.5;
}

.thumb-item:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.thumb-item.active {
    border-color: var(--accent);
    opacity: 1;
    transform: scale(1.05);
}

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

/* Details Content */
.modal-details {
    padding: 24px 24px 12px 24px;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .modal-details {
        padding: 32px 32px 16px 32px;
    }
}

.modal-category {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}

.modal-header-top {
    margin-bottom: 8px;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-year {
    font-size: 0.85rem;
    color: var(--text-subtle);
    letter-spacing: 0.05em;
    display: block;
}

.modal-description {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-primary);
    opacity: 0.85;
    margin-bottom: 16px;
    white-space: pre-wrap;
}

/* Quick Facts */
.quick-facts {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 36px;
    border: 1px solid color-mix(in srgb, var(--text-subtle) 10%, transparent);
}

.quick-facts h4 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 18px;
    color: var(--text-primary);
}

.facts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.fact-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fact-label {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.fact-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Sticky Actions panel */
.modal-actions-wrapper {
    margin-top: auto;
    padding: 20px 32px;
    background: var(--bg-primary);
    border-top: 1px solid color-mix(in srgb, var(--text-subtle) 15%, transparent);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 480px) {
    .modal-actions {
        flex-direction: row;
        justify-content: center;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        flex: 1;
        max-width: 300px;
        padding: 14px 20px;
        font-size: 0.8rem;
    }
}

/* ===========================
   DESKTOP TWO-COLUMN LAYOUT
   =========================== */
@media (min-width: 1024px) {
    .modal-body {
        overflow: hidden;
    }

    .modal-details {
        display: grid;
        grid-template-columns: 48% 52%;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "image header"
            "image description"
            "image actions";
        height: 100%;
        padding: 0;
    }

    .modal-image-container {
        grid-area: image;
        height: 100%;
        margin-bottom: 0;
        border-radius: 0;
        padding: 40px 20px 40px 40px;
    }

    .modal-header-top {
        grid-area: header;
        padding: 40px 40px 0 20px;
        margin-bottom: 24px;
    }

    .modal-description-wrapper {
        grid-area: description;
        padding: 0 40px 0 20px;
        overflow-y: auto;
    }

    .modal-actions-wrapper {
        grid-area: actions;
        position: relative;
        padding: 24px 40px 32px 20px;
    }
}

/* ===========================
   PREMIUM EVENT DETAILS MODAL
   =========================== */
dialog.event-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    overflow: hidden;
    z-index: 2100;
    display: none;
    align-items: center;
    justify-content: center;
}

dialog.event-modal[open] {
    display: flex;
}

dialog.event-modal::backdrop {
    background-color: rgba(10, 12, 11, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] dialog.event-modal::backdrop {
    background-color: rgba(245, 245, 245, 0.85);
}

.event-modal-container {
    position: relative;
    width: 90vw;
    max-width: 800px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid color-mix(in srgb, var(--text-subtle) 15%, transparent);
    animation: modalScaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.event-modal-img-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.event-modal-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-modal-body {
    padding: 36px;
}

.event-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(18, 18, 18, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F4F4F4;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition-smooth);
}

[data-theme="light"] .event-modal-close {
    background: rgba(250, 250, 250, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #2C3539;
}

.event-modal-close:hover {
    color: var(--accent);
    transform: scale(1.1) rotate(90deg);
}

/* Modal Info Grid for Additional Info */
.event-modal-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .event-modal-info-grid {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.event-modal-info-item {
    display: flex;
    flex-direction: column;
}

.event-modal-info-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 4px;
}

.event-modal-info-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Acknowledgement Chips */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    padding: 6px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition-smooth);
}

[data-theme="light"] .profile-chip {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.profile-chip:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    transform: translateY(-2px);
}

.profile-chip-name {
    font-size: 0.8rem;
    font-weight: 600;
}

.profile-chip-handle {
    font-size: 0.7rem;
    opacity: 0.7;
}

.profile-chip:hover .profile-chip-handle {
    color: var(--bg-primary);
    opacity: 0.9;
}

/* ===========================
   MOBILE SPECIFIC MODAL OVERRIDES
   =========================== */
@media (max-width: 768px) {
    .modal-content {
        width: 95vw;
        height: 90vh;
    }
    
    .modal-actions-wrapper {
        padding: 16px 16px;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 12px 10px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}
