/**
 * Dominican Bridge Design System - Components
 * Buttons, cards, filters, forms, badges
 */

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

/* Skip Link - Hidden until focused */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy);
    color: var(--white);
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    z-index: 10000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 16px;
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* Focus States - Consistent visible focus for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* Remove default outline for mouse users */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

/* Focus within cards - highlight the whole card */
.card:focus-within,
.event-card:focus-within,
.guide-card:focus-within,
.featured-card:focus-within {
    box-shadow: 0 0 0 2px var(--blue);
}

/* ==========================================================================
   DR FLAG
   ========================================================================== */

.dr-flag {
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height: auto;
    margin: 0 2px;
    border-radius: 2px;
}

/* ==========================================================================
   SHARE BUTTONS
   ========================================================================== */

.share-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.share-buttons-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.share-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--white);
}

.share-btn--whatsapp {
    background: #25D366;
}

.share-btn--facebook {
    background: #1877F2;
}

.share-btn--twitter {
    background: #000000;
}

.share-btn--linkedin {
    background: #0A66C2;
}

.share-btn--copy {
    background: var(--navy);
}

.share-btn--copy.copied {
    background: var(--green);
}

/* Share section styling */
.share-section {
    padding: 20px 0;
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Primary Button - Navy background */
.btn-primary {
    background: var(--navy);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--slate);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Secondary Button - White background */
.btn-secondary {
    background: var(--white);
    color: var(--navy);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--navy);
    color: var(--navy);
}

/* Outline Button - Transparent with border */
.btn-outline {
    background: transparent;
    color: var(--navy);
    border: 1px solid var(--navy);
}

.btn-outline:hover {
    background: var(--navy);
    color: var(--white);
}

/* Outline Light - For dark backgrounds */
.btn-outline-light {
    background: transparent;
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-outline-light:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
    color: var(--white);
}

/* Success Button - Green */
.btn-success {
    background: var(--green);
    color: var(--white);
}

.btn-success:hover {
    filter: brightness(1.1);
    color: var(--white);
}

/* Button Sizes */
.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-lg svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   CARDS
   ========================================================================== */

.card {
    background: var(--white);
    overflow: hidden;
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-body {
    padding: var(--space-lg);
}

.card-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--navy);
    margin-bottom: var(--space-sm);
    line-height: 1.3;
}

.card-title a {
    color: inherit;
    text-decoration: none;
}

.card-title a:hover {
    color: var(--blue);
}

.card-text {
    font-size: var(--text-base);
    color: var(--text-mid);
    line-height: 1.6;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-mid);
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-meta svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    opacity: 0.7;
}

.card-footer {
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Card with Image */
.card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/9; /* Prevent layout shift */
}

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

/* Square aspect ratio variant */
.card-image--square {
    aspect-ratio: 1/1;
}

/* Portrait aspect ratio variant */
.card-image--portrait {
    aspect-ratio: 3/4;
}

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

/* Horizontal Card */
.card-horizontal {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.card-horizontal .card-image {
    height: 100%;
    min-height: 220px;
}

/* ==========================================================================
   FILTERS
   ========================================================================== */

.filters {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 24px;
    background: var(--white);
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
}

.filter-btn:hover {
    color: var(--navy);
    box-shadow: var(--shadow-md);
}

.filter-btn.active {
    background: var(--navy);
    color: var(--white);
}

/* Filter overlapping hero */
.filters-overlap {
    margin-top: -30px;
    margin-bottom: var(--space-2xl);
}

/* Filter button variants */
.filter-btn.type-filter-btn {
    display: inline-block;
    text-decoration: none;
}

/* Select Dropdown Filter */
.filter-select {
    padding: 10px 36px 10px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    border: 1px solid var(--border);
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%235d6c7c'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") right 12px center no-repeat;
    appearance: none;
    cursor: pointer;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--blue);
}

/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: var(--text-md);
    border: 1px solid var(--border);
    background: var(--white);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(43, 123, 185, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-light);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%235d6c7c'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-hint {
    font-size: var(--text-sm);
    color: var(--text-light);
    margin-top: var(--space-xs);
}

.form-error {
    font-size: var(--text-sm);
    color: var(--red);
    margin-top: var(--space-xs);
}

/* ==========================================================================
   BADGES
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-primary {
    background: var(--navy);
    color: var(--white);
}

.badge-blue {
    background: var(--blue);
    color: var(--white);
}

.badge-success {
    background: var(--green);
    color: var(--white);
}

.badge-warning {
    background: var(--yellow);
    color: var(--navy);
}

/* ==========================================================================
   EMPTY STATES
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    background: var(--white);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: var(--border);
    margin-bottom: var(--space-lg);
}

.empty-state h3 {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    color: var(--navy);
    margin-bottom: var(--space-sm);
}

.empty-state p {
    color: var(--text-mid);
    max-width: 400px;
    margin: 0 auto;
}

/* Inline empty state - lighter, for use within sections */
.empty-state-inline {
    padding: var(--space-xl) var(--space-lg);
    background: var(--bone);
    text-align: center;
    border-radius: 4px;
}

.empty-state-inline p {
    color: var(--text-mid);
    font-size: var(--text-base);
    margin: 0;
}

.empty-state-inline a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}

.empty-state-inline a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--navy);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: var(--space-sm);
    transition: color var(--transition-base);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: var(--space-lg);
}

/* ==========================================================================
   BREADCRUMBS
   ========================================================================== */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-mid);
    margin-bottom: var(--space-lg);
}

.breadcrumb a {
    color: var(--text-mid);
    text-decoration: none;
    transition: color var(--transition-base);
}

.breadcrumb a:hover {
    color: var(--blue);
}

.breadcrumb-separator {
    color: var(--text-light);
    font-size: 10px;
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Light breadcrumb for dark backgrounds */
.breadcrumb-light {
    color: rgba(255,255,255,0.7);
}

.breadcrumb-light a {
    color: rgba(255,255,255,0.7);
}

.breadcrumb-light a:hover {
    color: var(--white);
}

.breadcrumb-light .breadcrumb-separator {
    color: rgba(255,255,255,0.4);
}

.breadcrumb-light .breadcrumb-current {
    color: var(--white);
}

@media (max-width: 480px) {
    .breadcrumb {
        font-size: 12px;
    }

    .breadcrumb-current {
        max-width: 120px;
    }
}

/* ==========================================================================
   READING PROGRESS BAR
   ========================================================================== */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--blue);
    z-index: 1000;
    transition: width 0.1s ease-out;
}

/* ==========================================================================
   BACK TO TOP BUTTON
   ========================================================================== */

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
    box-shadow: var(--shadow-lg);
    z-index: 99;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--blue);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    .back-to-top svg {
        width: 20px;
        height: 20px;
    }
}

/* ==========================================================================
   RECENTLY VIEWED
   ========================================================================== */

.recently-viewed {
    margin-bottom: var(--space-xl);
}

.recently-viewed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.recently-viewed-header h3 {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--navy);
    margin: 0;
}

.recently-viewed-clear {
    font-size: var(--text-sm);
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
}

.recently-viewed-clear:hover {
    color: var(--blue);
}

.recently-viewed-list {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    scrollbar-width: thin;
}

.recently-viewed-item {
    flex: 0 0 200px;
    background: var(--white);
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.recently-viewed-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.recently-viewed-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.recently-viewed-item-body {
    padding: var(--space-sm) var(--space-md);
}

.recently-viewed-item-type {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: 4px;
}

.recently-viewed-item-title {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--navy);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   TOUCH FEEDBACK (Mobile)
   ========================================================================== */

@media (hover: none) {
    /* Cards - subtle scale on tap */
    .card:active,
    .event-card:active,
    .featured-card:active,
    .guide-row:active,
    .feed-item:active,
    .related-card:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }

    /* Buttons - darken on tap */
    .btn:active,
    .btn-primary:active,
    .filter-btn:active,
    .share-btn:active {
        filter: brightness(0.9);
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .filter-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .filters-overlap {
        margin-top: -20px;
    }

    .card-horizontal {
        grid-template-columns: 1fr;
    }

    .card-horizontal .card-image {
        height: 200px;
        min-height: 200px;
    }

    .btn-lg {
        padding: 14px 24px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: var(--space-md);
    }

    .modal-content {
        margin: var(--space-md);
    }
}


/* ==========================================================================
   LOADING STATES
   ========================================================================== */

/* Spinner - inline or block */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

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

.spinner-white {
    border-color: rgba(255,255,255,0.3);
    border-top-color: var(--white);
}

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

/* Loading overlay for cards/sections */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--bone) 25%, #ece9e4 50%, var(--bone) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-sm);
    width: 100%;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-heading {
    height: 24px;
    width: 70%;
    margin-bottom: var(--space-md);
}

.skeleton-image {
    height: 200px;
    width: 100%;
    margin-bottom: var(--space-md);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}


/* ==========================================================================
   ALERTS & MESSAGES
   ========================================================================== */

.alert {
    padding: var(--space-md) var(--space-lg);
    border-left: 4px solid;
    margin-bottom: var(--space-lg);
    font-size: var(--text-sm);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.alert-success {
    background: #e8f5e9;
    border-color: var(--green);
    color: #2e7d32;
}

.alert-error {
    background: #ffebee;
    border-color: var(--red);
    color: #c62828;
}

.alert-warning {
    background: #fff8e1;
    border-color: var(--yellow);
    color: #e65100;
}

.alert-info {
    background: #e3f2fd;
    border-color: var(--blue);
    color: #1565c0;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.alert-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.alert-dismiss:hover {
    opacity: 1;
}


/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    background: var(--navy);
    color: var(--white);
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    pointer-events: auto;
    transform: translateY(16px);
    opacity: 0;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: #2e7d32;
}

.toast-error {
    background: #c62828;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    font-size: 16px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--white);
}

@media (max-width: 480px) {
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
    }

    .toast {
        max-width: none;
    }
}
