/**
 * User Profile - Responsive Media Queries
 *
 * Mobile, tablet, and desktop responsive adjustments
 * Most sizing is handled via clamp() in other files - this handles layout changes only
 *
 * @package PC Kompas User API
 */

/* ============================================================================
   TABLET BREAKPOINT (768px and below)
   Layout changes that cannot be handled by clamp()
   ============================================================================ */

@media (max-width: 768px) {
    /* Tab text visibility - show icons only on small tablets */
    .user-profile-tabs__tab span:not(.user-profile-tabs__badge) {
        display: none;
    }

    /* Tab navigation - ensure horizontal scroll is visible */
    .user-profile-tabs__nav {
        /* Show scrollbar for mobile scroll indication */
        scrollbar-width: thin;
        padding-bottom: 8px;
    }

    /* Card headers - stack meta info */
    .user-comment-card__header,
    .user-topic-card__meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Saved builds footer - stack actions */
    .saved-build-card__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .saved-build-card__actions {
        flex-direction: column;
    }

    .saved-build-card__actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Completed builds - uses .build-card classes, responsive handled by build-card.css */

    /* Touch target spacing - ensure 8px minimum between targets */
    .user-profile-subtabs {
        gap: 8px;
    }
}

/* Show tab text on larger tablets and up */
@media (min-width: 480px) {
    .user-profile-tabs__tab span:not(.user-profile-tabs__badge) {
        display: inline;
    }
}

/* ============================================================================
   SMALL MOBILE BREAKPOINT (480px and below)
   Additional layout simplifications
   ============================================================================ */

@media (max-width: 480px) {
    /* Favorite card actions - stack buttons */
    .favorite-card__actions {
        flex-direction: column;
        gap: 8px;
    }

    .favorite-card__actions .btn,
    .favorite-card__actions .btn-icon {
        width: 100%;
    }

    /* Icon buttons - ensure touch target */
    .btn-icon {
        width: 100%;
        min-width: 48px;
        min-height: 48px;
        padding: 12px 16px;
        justify-content: center;
    }

    /* Subtabs - ensure proper touch spacing */
    .user-profile-subtabs__item {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
    }

    /* Section headers - stack on very small */
    .user-profile-section__header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================================================
   MOBILE MESSAGING BREAKPOINT (640px and below)
   Modal and messaging layout changes
   ============================================================================ */

@media (max-width: 640px) {
    /* Compose modal - full screen on mobile */
    .compose-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal__header {
        padding: 16px 20px;
        /* Safe area for notched devices */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .modal__body {
        padding: 16px;
        max-height: calc(100vh - 160px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal__footer {
        position: sticky;
        bottom: 0;
        gap: 8px;
        padding: 12px 16px;
        /* Safe area for home indicator */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }

    .modal__footer .btn {
        flex: 1;
        min-height: 48px;
        justify-content: center;
    }

    .message-bubble {
        max-width: 85%;
    }

    /* Textarea in compose modal */
    .compose-modal textarea {
        min-height: 100px;
        max-height: 200px;
        font-size: 16px; /* Prevent iOS auto-zoom */
    }

    /* Message conversation card - touch friendly */
    .message-conversation-card {
        padding: 12px;
        width: 100%;
        min-height: 72px;
    }

    .message-conversation-card__avatar {
        width: 48px;
        height: 48px;
    }

    /* Inbox header buttons */
    .messages-inbox__header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .messages-inbox__header .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 120px;
        min-height: 48px;
        justify-content: center;
    }

    /* Conversation compose - safe area */
    .conversation-compose {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* ============================================================================
   EXTRA SMALL MOBILE (360px and below)
   Very compact layouts for small phones
   ============================================================================ */

@media (max-width: 360px) {
    .compose-modal {
        max-height: 100vh;
    }

    .modal__body {
        max-height: calc(100vh - 160px);
        padding: 12px;
    }

    /* All text inputs must be 16px to prevent iOS zoom */
    .form-input,
    .form-textarea,
    .compose-modal textarea,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    select {
        font-size: 16px !important;
    }

    .message-bubble {
        max-width: 90%;
    }

    /* Stack all card footers vertically */
    .user-build-card__footer,
    .saved-build-card__footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .user-build-card__footer .btn,
    .saved-build-card__footer .btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    /* Subtabs - single column */
    .user-profile-subtabs {
        flex-direction: column;
    }

    .user-profile-subtabs__item {
        width: 100%;
        justify-content: center;
    }

    /* Favorite card - reduce padding */
    .favorite-card__content {
        padding: 12px;
    }

    .favorite-card__actions {
        padding: 10px 12px;
    }
}

/* ============================================================================
   REDUCED MOTION
   Respect user's motion preferences
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .user-profile-tabs__tab,
    .account-sidebar__item,
    .user-comment-card,
    .user-topic-card,
    .user-build-card,
    .favorite-card,
    .saved-build-card,
    .build-card,
    .toggle-switch__slider,
    .toggle-switch__slider:before,
    .btn,
    .btn-icon,
    .form-input,
    .form-textarea,
    .theme-selector__card,
    .account-sidebar__toggle-icon {
        transition: none !important;
    }

    .favorite-card:hover .favorite-card__image img {
        transform: none;
    }

    .toggle-switch__loading,
    .notification-loading__spinner,
    .user-profile-loading .spinner {
        animation: none;
    }
}

/* ============================================================================
   HIGH CONTRAST MODE
   Improve visibility for users with visual impairments
   ============================================================================ */

@media (prefers-contrast: more) {
    .user-profile-tabs__tab--active {
        border-bottom-width: 3px;
    }

    .form-input:focus,
    .form-textarea:focus {
        box-shadow: 0 0 0 4px var(--accent);
    }

    .btn-icon:focus-visible,
    .user-profile-tabs__tab:focus-visible,
    .account-sidebar__item:focus-visible {
        outline-width: 3px;
    }
}

/* ============================================================================
   PRINT STYLES
   Clean print output
   ============================================================================ */

@media print {
    .user-profile-tabs,
    .user-profile-header__actions,
    .account-sidebar,
    .user-profile-pagination,
    .btn-icon,
    .favorite-card__actions,
    .saved-build-card__actions,
    .build-card__action-btn {
        display: none !important;
    }

    .user-profile-page {
        min-height: auto;
    }

    .user-profile-content {
        padding: 0;
    }

    .user-profile-header {
        background: none;
        border: none;
        padding: 1rem 0;
    }

    .account-layout {
        display: block;
    }

    .settings-group,
    .user-comment-card,
    .user-topic-card,
    .user-build-card,
    .favorite-card,
    .saved-build-card,
    .build-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
