/* =============================================================================
   SWIPE REVEAL (sr-) - Swipe left/right to reveal action buttons
   Pure CSS with scroll-snap - works on Safari
   ============================================================================= */

/* Card list container */
.sr-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem;
}

/* Card wrapper - horizontal scroll container
   Uses container queries so center panel can be 100cqw (container width, not viewport) */
.sr-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    background: #f5f5f5;
    container-type: inline-size;
}

.sr-card::-webkit-scrollbar {
    display: none;
}

/* Left action (Shares) */
.sr-action-left {
    width: 265px;
    min-height: 0;
    scroll-snap-align: start;
    -webkit-scroll-snap-align: start;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    background: rgba(0, 102, 204, 0.08);
    border-right: 1px solid rgba(0, 102, 204, 0.2);
    border-radius: 0.75rem 0 0 0.75rem;
    overflow: hidden;
}

/* Center - main card content */
.sr-content {
    width: 100cqw;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    -webkit-scroll-snap-align: start;
    -webkit-scroll-snap-stop: always;
    background: #fff;
    border: 1px solid #e0e0e0;
}

/* Right action (Delete) */
.sr-action-right {
    width: 80px;
    min-height: 0;
    scroll-snap-align: end;
    -webkit-scroll-snap-align: end;
    display: flex;
    align-items: stretch;
}

/* Action buttons */
.sr-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    gap: 0.25rem;
    touch-action: manipulation;
}

.sr-action-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Shares Panel */
.sr-shares-header {
    padding: 0.5rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #0066cc;
    flex-shrink: 0;
    text-align: center;
}

.sr-shares-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.sr-shares-cols {
    display: grid;
    grid-template-columns: 1fr 3.5rem 3rem 1.5rem;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #999;
    border-bottom: 1px solid rgba(0, 102, 204, 0.15);
}

.sr-shares-cols span {
    padding: 0.125rem 0;
}

.sr-share-row {
    display: grid;
    grid-template-columns: 1fr 3.5rem 3rem 1.5rem;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    align-items: center;
    border-bottom: 1px solid rgba(0, 102, 204, 0.1);
}

.sr-share-name {
    min-width: 0;
    padding: 0.25rem 0;
    font-size: 0.875rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-share-time {
    font-size: 0.6875rem;
    color: #666;
    text-align: left;
    min-width: 2.5rem;
}

.sr-share-status {
    font-size: 0.75rem;
    text-align: left;
    min-width: 2.5rem;
}

.sr-share-status-claimed {
    color: #059669;
}

.sr-share-status-pending {
    color: #ccc;
}

.sr-share-delete {
    padding: 0.25rem;
    color: #ccc;
    background: none;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 1.5rem;
    text-align: center;
    touch-action: manipulation;
}

.sr-share-delete:active {
    color: #dc2626;
}

.sr-shares-empty {
    padding: 1rem 0.625rem;
    color: #666;
    font-size: 0.75rem;
    font-style: italic;
    text-align: center;
}

/* =============================================================================
   SHARES PANEL - Simple toggle button + show/hide
   ============================================================================= */

.sr-shares-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.5rem;
    margin-bottom: 0;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    touch-action: manipulation;
}

.sr-shares-toggle svg {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.sr-shares-arrow {
    margin-left: auto;
    font-size: 0.625rem;
}

.sr-shares-header-row {
    display: grid;
    grid-template-columns: 1fr 3rem 3.5rem 1.5rem;
    gap: 0.5rem;
    margin: 0 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.625rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Share row wrapper - instant show/hide */
.sr-share-row-wrapper {
    margin: 0 0.5rem;
}

.sr-share-row-wrapper .sr-share-row-inner {
    display: grid;
    grid-template-columns: 1fr 3rem 3.5rem 1.5rem;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0f9ff;
    border: 1px solid #e2e8f0;
    border-top: none;
    font-size: 0.8125rem;
}

.sr-share-row-inner .sr-share-recipient {
    color: #0369a1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-share-row-inner .sr-share-sent,
.sr-share-row-inner .sr-share-claimed {
    font-size: 0.6875rem;
    color: #666;
    text-align: center;
}

.sr-share-row-inner .sr-share-claimed.is-claimed {
    color: #059669;
}

.sr-share-row-inner .sr-share-delete {
    padding: 0.25rem;
    color: #9ca3af;
    background: none;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    touch-action: manipulation;
    text-align: center;
}

.sr-share-row-inner .sr-share-delete:active {
    color: #dc2626;
}

/* Delete button style */
.sr-btn-delete {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border-radius: 0 0.75rem 0.75rem 0;
}

.sr-btn-delete:active {
    background: rgba(220, 38, 38, 0.3);
}

/* Card content layout */
.sr-inner {
    padding: 0.625rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto auto auto auto;
    grid-template-areas:
        "number airline date"
        "origin arrow dest"
        "depart . arrive"
        "progress progress progress"
        "remaining remaining remaining"
        ". status share";
    gap: 0.375rem 0.5rem;
}

.sr-flight-number {
    grid-area: number;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
}

.sr-airline {
    grid-area: airline;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
}

.sr-date {
    grid-area: date;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.sr-origin {
    grid-area: origin;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
}

.sr-destination {
    grid-area: dest;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.sr-arrow {
    grid-area: arrow;
    font-size: 1rem;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
}

.sr-departure {
    grid-area: depart;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    padding-bottom: 0.375rem;
}

.sr-arrival {
    grid-area: arrive;
    font-size: 0.875rem;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0.375rem;
}

.sr-status {
    grid-area: status;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    border-top: 1px solid #e8e8e8;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

/* Status colors */
.sr-status-scheduled { color: #64748b; }
.sr-status-enroute, .sr-status-departed { color: #4b7bb5; }
.sr-status-landed { color: #059669; }
.sr-status-delayed { color: #b45309; }
.sr-status-cancelled { color: #9f1239; }
.sr-status-diverted { color: #7c3aed; }

.sr-btn-share {
    grid-area: share;
    justify-self: end;
    border-top: 1px solid #e8e8e8;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.sr-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 4rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    touch-action: manipulation;
}

.sr-btn:hover {
    background: #eee;
    border-color: #ccc;
}

.sr-btn:active {
    background: #e0e0e0;
}

.sr-btn svg {
    width: 1rem;
    height: 1rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.sr-btn-share {
    color: var(--accent-color, #0066cc);
}

.sr-card-wrapper {
    position: relative;
}

/* Progress bar */
.sr-timer-bar {
    grid-area: progress;
    width: 100%;
    height: 0.5rem;
    background: #e0e0e0;
    border-radius: 0.25rem;
    overflow: hidden;
    margin-top: 0.25rem;
}

.sr-timer-fill {
    height: 100%;
    background: #0066cc;
    border-radius: 0.25rem;
    transform-origin: left center;
}

.sr-timer-countdown .sr-timer-fill {
    animation: timer-drain calc(var(--duration, 3600) * 1s) linear forwards;
}

@keyframes timer-drain {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.sr-timer-inflight .sr-timer-fill {
    transform: scaleX(var(--current, 0));
    animation: timer-fill calc(var(--duration, 3600) * 1s) linear forwards;
}

@keyframes timer-fill {
    to { transform: scaleX(1); }
}

.sr-time-remaining {
    grid-area: remaining;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0066cc;
    text-align: center;
    padding-bottom: 0.25rem;
}

/* New share flash animation */
@keyframes share-flash {
    0% { background-color: rgba(0, 102, 204, 0.3); }
    50% { background-color: rgba(0, 102, 204, 0.15); }
    100% { background-color: transparent; }
}

@keyframes input-pulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.5);
        border-color: #0066cc;
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(0, 102, 204, 0.3);
        border-color: #0066cc;
    }
}

.sr-share-new {
    animation: share-flash 1.5s ease-out;
}

.sr-share-new .sr-share-name {
    animation: input-pulse 1s ease-in-out 3;
}

/* =============================================================================
   SHARE NAME POPOVER - Modern Popover API
   ============================================================================= */

#share-name-popover {
    /* Position near top so keyboard doesn't cover it */
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;

    /* Sizing */
    max-width: 20rem;
    width: calc(100% - 2rem);

    /* Appearance */
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
}

#share-name-popover h3 {
    margin: 0 0 0.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
}

.popover-hint {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: #666;
}

.popover-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    background: #fafafa;
    transition: border-color 0.2s, background-color 0.2s;
}

.popover-input:focus {
    outline: none;
    border-color: var(--accent-color, #0066cc);
    background: #fff;
}

.popover-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.popover-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
}

.popover-btn:active {
    transform: scale(0.98);
}

.popover-btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.popover-btn-secondary:hover {
    background: #e8e8e8;
}

.popover-btn-primary {
    background: var(--accent-color, #0066cc);
    color: #fff;
}

.popover-btn-primary:hover {
    background: #0055aa;
}

.popover-btn-danger {
    background: #dc2626;
    color: #fff;
}

.popover-btn-danger:hover {
    background: #b91c1c;
}

.popover-message {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: #1a1a1a;
    text-align: center;
}

#delete-confirm-popover {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    max-width: 20rem;
    width: calc(100% - 2rem);
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
}

#delete-confirm-popover::backdrop {
    background: rgba(0, 0, 0, 0.3);
}

#claim-share-popover {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    max-width: 20rem;
    width: calc(100% - 2rem);
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
}

#claim-share-popover h3 {
    margin: 0 0 0.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
}

#claim-share-popover::backdrop {
    background: rgba(0, 0, 0, 0.3);
}

/* Backdrop styling */
#share-name-popover::backdrop {
    background: rgba(0, 0, 0, 0.3);
}
