/* ===================================
   RESPONSIVE COMPONENT STYLES
   =================================== */

/* Mobile Search Modal */
.mobile-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.mobile-search-container {
    width: 100%;
    max-width: 500px;
    position: relative;
}

.mobile-search-container .search-form {
    width: 100%;
}

.mobile-search-container input {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    background: white;
}

.close-search {
    position: absolute;
    top: -3rem;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Mobile Search Toggle */
.mobile-search-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--foreground);
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    /* Keep clear of the Chaskiq launcher in the bottom-right corner. */
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6rem);
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
        right: 1rem;
        width: 44px;
        height: 44px;
    }
}

/* Body Menu Open State */
body.menu-open {
    overflow: hidden;
}

/* Error Messages */
.error-message {
    display: block;
    color: var(--destructive);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

input.error,
textarea.error,
select.error {
    border-color: var(--destructive);
}

/* Responsive Accordion for Mobile */
@media (max-width: 768px) {
    .accordion {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        overflow: hidden;
    }
    
    .accordion-item {
        border-bottom: 1px solid var(--border);
    }
    
    .accordion-item:last-child {
        border-bottom: none;
    }
    
    .accordion-header {
        padding: 1rem;
        background: var(--secondary);
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .accordion-header:after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        transition: transform 0.3s ease;
    }
    
    .accordion-item.active .accordion-header:after {
        transform: rotate(180deg);
    }
    
    .accordion-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        padding: 0 1rem;
    }
    
    .accordion-item.active .accordion-content {
        max-height: 500px;
        padding: 1rem;
    }
}

/* Touch-friendly Tabs */
@media (max-width: 768px) {
    .tabs {
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        display: inline-block;
        padding: 1rem 1.5rem;
        border: none;
        background: none;
        cursor: pointer;
        position: relative;
        color: var(--muted-foreground);
        min-width: 100px;
    }
    
    .tab-button.active {
        color: var(--primary);
    }
    
    .tab-button.active:after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: var(--primary);
    }
    
    .tab-content {
        padding: 1.5rem 1rem;
    }
    
    .tab-pane {
        display: none;
    }
    
    .tab-pane.active {
        display: block;
    }
}

/* Responsive Cards */
@media (max-width: 768px) {
    .card {
        border-radius: var(--radius);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 1rem;
        background: var(--secondary);
        border-bottom: 1px solid var(--border);
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-footer {
        padding: 1rem;
        background: var(--secondary);
        border-top: 1px solid var(--border);
    }
}

/* Responsive Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
}

@media (max-width: 768px) {
    .badge {
        padding: 0.375rem 0.625rem;
        font-size: 0.875rem;
    }
}

/* Responsive Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error,
.alert-danger {
    background: rgba(var(--destructive-rgb), 0.1);
    color: var(--destructive);
    border: 1px solid var(--destructive);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid #ffc107;
}

.alert-info {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
}

@media (max-width: 768px) {
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Responsive Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    margin: 2rem 0;
}

.pagination a,
.pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background: white;
    color: var(--foreground);
    text-decoration: none;
    transition: all 0.3s ease;
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active,
.pagination .current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination a,
    .pagination span {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hide some page numbers on mobile */
    .pagination a:not(.prev):not(.next):not(.active):nth-child(n+4):nth-last-child(n+4) {
        display: none;
    }
}

/* Responsive Breadcrumbs */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: nowrap;
}

.breadcrumb a {
    color: var(--muted-foreground);
    text-decoration: none;
}

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

.breadcrumb .separator {
    color: var(--muted-foreground);
}

@media (max-width: 768px) {
    .breadcrumb {
        font-size: 0.75rem;
        padding: 0.75rem 0;
    }
}

/* Responsive Loading Spinner */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Responsive Tooltips */
@media (hover: hover) and (pointer: fine) {
    [data-tooltip] {
        position: relative;
        cursor: help;
    }
    
    [data-tooltip]:hover:after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.5rem 0.75rem;
        background: rgba(0, 0, 0, 0.9);
        color: white;
        font-size: 0.875rem;
        white-space: nowrap;
        border-radius: var(--radius);
        margin-bottom: 0.5rem;
        z-index: 1000;
    }
}

/* Touch-friendly tooltips for mobile */
@media (hover: none) and (pointer: coarse) {
    [data-tooltip] {
        text-decoration: underline;
        text-decoration-style: dotted;
    }
}
