/* ==========================================================================
   Metroplex 360 - Digital Asset Management
   Custom Styles (supplements Tailwind CSS)
   ========================================================================== */

/* --------------------------------------------------------------------------
   HTMX Indicator Styles
   -------------------------------------------------------------------------- */

/* Default: hidden. HTMX adds .htmx-request to the indicator's parent */
.htmx-indicator {
    display: none;
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
    opacity: 1;
}

/* Inline spinner variant for buttons */
.htmx-indicator.inline {
    display: none;
}

.htmx-request .htmx-indicator.inline,
.htmx-request.htmx-indicator.inline {
    display: inline-flex;
}

/* Subtle loading bar at the top of the page */
.htmx-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: #5B7FA6;
    z-index: 9999;
    transition: width 300ms ease;
}

/* --------------------------------------------------------------------------
   Lightbox Overlay
   -------------------------------------------------------------------------- */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 300ms ease;
}

.lightbox-overlay.active img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 200ms ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 200ms ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav.prev {
    left: 1rem;
}

.lightbox-nav.next {
    right: 1rem;
}

.lightbox-caption {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    max-width: 80%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Star Rating Interactive Styles
   -------------------------------------------------------------------------- */

.star-rating {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 0.125rem;
}

.star-rating input {
    display: none;
}

.star-rating label {
    cursor: pointer;
    color: #d1d5db;
    transition: color 150ms ease;
    font-size: 0;
    line-height: 1;
}

.star-rating label svg {
    width: 1.5rem;
    height: 1.5rem;
    transition: color 150ms ease, transform 150ms ease;
}

/* Fill stars on hover and when checked */
.star-rating label:hover svg,
.star-rating label:hover ~ label svg {
    color: #fbbf24;
    transform: scale(1.1);
}

.star-rating input:checked ~ label svg {
    color: #f59e0b;
}

/* When hovering while some are checked, show hover state */
.star-rating:hover input:checked ~ label svg {
    color: #d1d5db;
}

.star-rating:hover label:hover svg,
.star-rating:hover label:hover ~ label svg {
    color: #fbbf24;
}

/* Read-only star display */
.star-display {
    display: inline-flex;
    gap: 0.0625rem;
}

.star-display .star-filled {
    color: #f59e0b;
}

.star-display .star-empty {
    color: #d1d5db;
}

/* --------------------------------------------------------------------------
   Image Card Hover Overlay
   -------------------------------------------------------------------------- */

.image-card {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    cursor: pointer;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 300ms ease;
}

.image-card:hover img {
    transform: scale(1.05);
}

.image-card .image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 250ms ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
}

.image-card:hover .image-overlay {
    opacity: 1;
}

.image-card .image-overlay-top {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 250ms ease;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0.75rem;
}

.image-card:hover .image-overlay-top {
    opacity: 1;
}

.image-card .image-actions {
    display: flex;
    gap: 0.5rem;
}

.image-card .image-actions button,
.image-card .image-actions a {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem;
    color: white;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.image-card .image-actions button:hover,
.image-card .image-actions a:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Image card checkbox (top-left corner) */
.image-card .image-checkbox {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    opacity: 0;
    transition: opacity 200ms ease;
}

.image-card:hover .image-checkbox,
.image-card .image-checkbox.checked {
    opacity: 1;
}

.image-card .image-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.25rem;
    border: 2px solid white;
    background: rgba(0, 0, 0, 0.3);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.image-card .image-checkbox input[type="checkbox"]:checked {
    background: #3b82f6;
    border-color: #3b82f6;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   Custom Scrollbar (Sidebar)
   -------------------------------------------------------------------------- */

.sidebar-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(147, 197, 253, 0.3) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(147, 197, 253, 0.3);
    border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(147, 197, 253, 0.5);
}

/* --------------------------------------------------------------------------
   Gallery Grid Layouts
   -------------------------------------------------------------------------- */

.gallery-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

@media (min-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

.gallery-grid .image-card {
    aspect-ratio: 4 / 3;
}

/* --------------------------------------------------------------------------
   Selection Toolbar (appears when images are selected)
   -------------------------------------------------------------------------- */

.selection-toolbar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    z-index: 40;
    background: #1e3a5f;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    transition: transform 300ms ease, opacity 300ms ease;
}

.selection-toolbar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Alpine.js x-cloak (hide until Alpine initializes)
   -------------------------------------------------------------------------- */

[x-cloak] {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */

@media print {
    /* Hide navigation and interactive elements */
    nav,
    header,
    aside,
    .print\\:hidden,
    .htmx-indicator,
    .selection-toolbar,
    .lightbox-overlay,
    button[aria-label="Dismiss"],
    .image-checkbox,
    .image-overlay,
    .image-overlay-top {
        display: none !important;
    }

    /* Reset layout for printing */
    body {
        background: white !important;
        color: black !important;
    }

    main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure images print cleanly */
    .image-card img {
        break-inside: avoid;
        max-width: 100%;
    }

    /* Show URLs after links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.75rem;
        color: #666;
    }

    a[href^="#"]:after,
    a[href^="javascript"]:after {
        content: "";
    }
}

/* --------------------------------------------------------------------------
   Transition Utilities
   -------------------------------------------------------------------------- */

.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    transition: opacity 300ms ease;
}

.fade-enter-to {
    opacity: 1;
}

.fade-leave {
    opacity: 1;
}

.fade-leave-active {
    transition: opacity 200ms ease;
}

.fade-leave-to {
    opacity: 0;
}

/* Slide up animation for modals */
.slide-up-enter {
    opacity: 0;
    transform: translateY(1rem);
}

.slide-up-enter-active {
    transition: opacity 300ms ease, transform 300ms ease;
}

.slide-up-enter-to {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Loading Spinner
   -------------------------------------------------------------------------- */

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

.spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 1.5px;
}

.spinner-lg {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
}

/* Pulse animation for action feedback */
@keyframes pulse-once {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.action-pulse {
    animation: pulse-once 0.3s ease;
}

/* --------------------------------------------------------------------------
   Table Scroll Indicators
   -------------------------------------------------------------------------- */

.table-scroll-wrapper {
    position: relative;
}

/* Fade-out shadows on scrollable edges */
.table-scroll-wrapper::before,
.table-scroll-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 200ms ease;
}

.table-scroll-wrapper::before {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
}

.table-scroll-wrapper::after {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.06), transparent);
}

/* JS toggles these classes based on scroll position */
.table-scroll-wrapper.can-scroll-left::before { opacity: 1; }
.table-scroll-wrapper.can-scroll-right::after { opacity: 1; }

/* Compact table cells */
.table-compact th,
.table-compact td {
    padding-left: 0.75rem;   /* px-3 */
    padding-right: 0.75rem;
}

.table-compact th:first-child,
.table-compact td:first-child {
    padding-left: 1rem;
}

.table-compact th:last-child,
.table-compact td:last-child {
    padding-right: 1rem;
}

/* --------------------------------------------------------------------------
   Sortable Table Headers
   -------------------------------------------------------------------------- */

th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th[data-sort]:hover {
    color: #1e3a5f;
}

.sort-indicator {
    font-size: 0.65em;
    opacity: 0.7;
    margin-left: 0.25em;
}

/* --------------------------------------------------------------------------
   Drag & Drop Upload Zone
   -------------------------------------------------------------------------- */

.dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    transition: border-color 200ms ease, background-color 200ms ease;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: #5B7FA6;
    background-color: #eef2f7;
}

.dropzone.uploading {
    border-color: #5B7FA6;
    background-color: #eef2f7;
    cursor: default;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Gallery Filmstrip — delivery status band in community list rows
   Each segment represents a proportion of galleries in a given status.
   Statuses ordered: Delivered → Ready → Draft → Archived (left to right)
   -------------------------------------------------------------------------- */

.gallery-strip {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #E4DFD9;   /* warm neutral base — visible when no galleries in a status */
    min-width: 72px;
    flex-shrink: 0;
}

.gallery-strip-segment {
    transition: opacity 120ms ease;
    min-width: 2px;         /* single gallery always has a sliver */
}

.gallery-strip:hover .gallery-strip-segment {
    opacity: 0.75;
}

/* Delivered: muted professional green — work completed, handed off */
.gallery-strip-segment.status-delivered { background: #4A8B6F; }

/* Ready: slate-steel accent — staged, waiting on client */
.gallery-strip-segment.status-ready     { background: #5B7FA6; }

/* Draft: warm sand — in progress, not staged */
.gallery-strip-segment.status-draft     { background: #B8B0A4; }

/* Archived: warm amber-tan — historical, off the active path */
.gallery-strip-segment.status-archived  { background: #A8956E; }
