/* 📱 MOBILE RESPONSIVE CSS */

/* Tablets and Small Desktops */
@media (max-width: 1024px) {
    .container {
        max-width: 960px;
        padding: 0 1.5rem;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Tablets */
@media (max-width: 768px) {
    /* Container */
    .container {
        padding: 0 0.5rem !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* Prevent horizontal scroll */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Ensure all sections stay within bounds */
    section {
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    section > .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Header */
    header {
        padding: 0.75rem 0;
    }
    
    header .header-content {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Show mobile menu button */
    .mobile-menu-toggle {
        display: block !important;
        z-index: 1001;
    }
    
    /* Hide desktop nav by default on mobile */
    header nav {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 80vw;
        background: var(--card);
        border-left: 1px solid var(--border);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        padding: 5rem 0 2rem 0;
        overflow-y: auto;
    }
    
    /* Show nav when mobile-open class is added */
    header nav.mobile-open {
        display: flex;
        flex-direction: column;
        animation: slideInRight 0.3s ease-out;
    }
    
    header nav a {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        font-weight: 500;
        text-align: left;
        border-bottom: 1px solid var(--border);
        transition: all 0.2s;
    }
    
    header nav a:hover {
        background: var(--muted);
        padding-left: 2rem;
    }
    
    @keyframes slideInRight {
        from {
            transform: translateX(100%);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }
    
    /* Logo */
    .logo {
        font-size: 1.25rem !important;
    }
    
    .logo-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.25rem !important;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.8125rem !important;
    }
    
    .btn-lg {
        padding: 0.625rem 1.25rem !important;
        font-size: 0.9375rem !important;
    }
    
    /* Tools Layout */
    .tools-layout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 1rem !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .tools-layout aside {
        display: none !important;
    }
    
    .tools-layout main {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Grid */
    .grid,
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-md-2,
    .grid-cols-lg-3,
    .tools-grid,
    .prompts-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Cards */
    .card {
        padding: 0.75rem !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        margin: 0 !important;
    }
    
    .card-header {
        padding: 1rem !important;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .card-content {
        padding: 1rem !important;
        max-width: 100%;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .card-footer {
        padding: 1rem !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Prompt/Tool Cards specific */
    .tool-card {
        max-width: 100% !important;
        width: 100% !important;
        position: relative !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }
    
    .tool-card-logo {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        position: relative;
        min-height: 180px;
        height: 180px;
    }
    
    .tool-card-logo img {
        max-width: 100%;
        width: 100%;
        height: auto;
        object-fit: cover;
    }
    
    .tool-card-body {
        max-width: 100% !important;
        padding: 0.75rem !important;
        box-sizing: border-box !important;
    }
    
    .tool-card-title {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
        font-size: 1rem !important;
    }
    
    .tool-card-cta {
        max-width: 100% !important;
        padding: 0.75rem !important;
        box-sizing: border-box !important;
    }
    
    .tool-card-cta p {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    .tool-card-meta {
        max-width: 100% !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    /* Ensure all images stay within bounds */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Badge adjustments */
    .badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Typography */
    .section-title {
        font-size: 1.75rem !important;
    }
    
    .hero-section {
        text-align: center !important;
        margin-bottom: 2rem !important;
        padding: 0 !important;
    }
    
    .hero-title {
        font-size: 1.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .hero-description {
        font-size: 1rem !important;
        margin: 0 auto 1.5rem !important;
        max-width: 100% !important;
    }
    
    h1 {
        font-size: 1.875rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    /* Search */
    .search-hero {
        padding: 2.5rem 0 1.5rem !important;
        border-bottom: none !important;
    }
    
    .search-hero-grid {
        flex-direction: column !important;
        gap: 1.5rem !important;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: calc(var(--radius) * 1.5);
        padding: 1.5rem;
        box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
    }
    
    .search-hero-info,
    .search-form {
        width: 100% !important;
    }
    
    .search-hero-eyebrow {
        justify-content: center;
    }
    
    .search-hero-title {
        text-align: center;
        font-size: 2rem !important;
    }
    
    .search-hero-description,
    .search-hero-meta {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }
    
    .search-language-toggle {
        flex-direction: column;
        gap: 0.35rem !important;
        text-align: center;
    }
    
    .search-language-options {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem !important;
    }
    
    .language-pill {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 140px;
        justify-content: center;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
    }

    .workflow-language-toggle {
        gap: 0.35rem !important;
    }

    .workflow-language-options {
        justify-content: center;
    }
    
    .search-form {
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
    }
    
    .search-form-inner {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.4rem !important;
        padding: 0.4rem !important;
        border-radius: var(--radius);
        border: 1px solid rgba(148, 163, 184, 0.25);
        background: var(--background);
    }
    
    .search-form-inner.has-select {
        display: flex !important;
        flex-direction: column !important;
    }

    .breadcrumbs .container {
        padding: 0.5rem 1rem !important;
    }

    .breadcrumbs ol {
        font-size: 0.75rem !important;
        gap: 0.5rem !important;
    }
    
    .search-input-wrapper {
        width: 100%;
        order: 1;
        background: var(--card);
        border: 1px solid rgba(148, 163, 184, 0.4);
        border-radius: var(--radius);
        padding: 0.4rem 0.6rem;
        min-height: 34px;
        max-height: 34px;
        display: flex !important;
        align-items: center;
    }
    
    .search-select-wrapper {
        width: 100%;
        order: 2;
        background: var(--card);
        border: 1px solid rgba(148, 163, 184, 0.4);
        border-radius: var(--radius);
        padding: 0.4rem 0.6rem;
        min-height: 34px;
        max-height: 34px;
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }
    
    .search-select-wrapper svg {
        flex-shrink: 0;
        width: 12px;
        height: 12px;
        opacity: 0.5;
    }
    
    .search-input {
        font-size: 0.8125rem !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        height: 26px !important;
        max-height: 26px !important;
        line-height: 26px !important;
        resize: none !important;
        width: 100% !important;
    }
    
    .search-select {
        width: 100%;
        padding: 0 !important;
        font-size: 0.8125rem !important;
        border: none !important;
        background: transparent !important;
        height: 26px !important;
        max-height: 26px !important;
        line-height: 26px !important;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right center;
        background-size: 10px;
        padding-right: 1rem !important;
    }
    
    .search-submit-btn {
        width: 100%;
        padding: 0.5rem 0.875rem !important;
        order: 3;
        justify-content: center !important;
        border-radius: var(--radius);
        font-size: 0.8125rem !important;
        display: flex;
        align-items: center;
        font-weight: 600 !important;
        min-height: 34px;
        max-height: 34px;
    }
    
    .search-submit-btn svg {
        width: 12px;
        height: 12px;
        margin-right: 0.35rem !important;
    }
    
    .search-wrapper {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .search-input {
        width: 100% !important;
    }
    
    .search-btn {
        width: 100% !important;
    }
    
    .search-form-hint {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.25rem;
    }
    
    .active-filters-bar {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
    }
    
    /* Tables */
    table {
        font-size: 0.8125rem !important;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table th,
    table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Profile */
    .profile-header {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 1rem;
    }
    
    .profile-avatar-large {
        margin: 0 auto;
    }
    
    .profile-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem !important;
    }
    
    .profile-tab {
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
        white-space: nowrap;
    }
    
    /* Tabs */
    .tabs-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem !important;
    }
    
    .tab-button {
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
        white-space: nowrap;
    }
    
    /* Badges */
    .badge {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    /* Spacing */
    .section {
        padding: 2rem 0 !important;
    }
    
    main.section {
        padding: 2rem 0 !important;
    }
    
    /* Modal */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem !important;
    }
    
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    /* Extra small adjustments */
    .container {
        padding: 0 0.5rem !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Workflow logo on mobile */
    .tool-card-logo {
        height: 160px !important;
        min-height: 160px !important;
    }
    
    /* Ensure cards don't overflow */
    .card,
    .tool-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0.5rem !important;
    }
    
    .detail-actions {
        grid-template-columns: 1fr !important;
    }

    .detail-actions .detail-action-btn:first-child {
        grid-column: auto !important;
    }

    .detail-actions .detail-action-btn {
        min-width: 100% !important;
        font-size: 0.875rem !important;
        padding: 0.65rem 0.75rem !important;
    }
    
    .tool-card-body,
    .tool-card-cta {
        padding: 0.5rem !important;
    }
    
    /* Reduce gaps */
    .grid,
    .tools-grid,
    .prompts-grid {
        gap: 0.5rem !important;
    }
    
    .section-title {
        font-size: 1.5rem !important;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
    }
    
    h3 {
        font-size: 1.125rem !important;
    }
    
    .btn {
        padding: 0.5rem 0.875rem !important;
        font-size: 0.8125rem !important;
    }
    
    .card {
        padding: 0.875rem !important;
    }
    
    .profile-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Landscape phones */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 0.5rem 0;
    }
    
    .section {
        padding: 1.5rem 0 !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    a,
    button {
        min-height: 44px; /* iOS touch target */
        min-width: 44px;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
    }
}

