/**
 * Mobile-Specific Fixes for HomilyWriterAI
 * This file contains ONLY mobile-specific fixes (max-width: 768px)
 * Desktop styles remain untouched
 * Version: 1.0.0
 */

/* ============================================
   DASHBOARD MOBILE FIXES
   ============================================ */

@media (max-width: 768px) {
    /* Sidebar responsive behavior */
    .dashboard-sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 999 !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
    }

    .dashboard-sidebar.active {
        left: 0 !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2) !important;
    }

    /* Mobile overlay for sidebar */
    .mobile-sidebar-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        z-index: 998 !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
    }

    .mobile-sidebar-overlay.active {
        display: block !important;
        opacity: 1 !important;
    }

    /* Dashboard main content takes full width on mobile */
    .dashboard-main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Dashboard header */
    .dashboard-header {
        padding: 0.75rem 1rem !important;
        flex-wrap: nowrap !important;
    }

    .dashboard-header .header-title h2 {
        font-size: 1.2rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .header-logo {
        margin-right: 0.5rem !important;
    }

    .header-logo .small-logo {
        max-width: 30px !important;
        max-height: 30px !important;
    }

    .header-actions {
        gap: 0.5rem !important;
    }

    .header-icon-btn {
        width: 36px !important;
        height: 36px !important;
        padding: 0.5rem !important;
    }

    /* Welcome Banner */
    .welcome-banner {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .welcome-message {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .referral-banner {
        margin-top: 0.75rem !important;
    }

    .referral-link {
        font-size: 0.9rem !important;
        padding: 0.75rem 1.25rem !important;
        display: inline-block !important;
        word-break: break-word !important;
    }

    /* Dashboard Content */
    .dashboard-content {
        padding: 1rem !important;
    }

    /* Content Cards */
    .content-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .content-header h3 {
        font-size: 1.3rem !important;
    }

    /* Homilies Grid - Stack on mobile */
    .homilies-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Homily Card */
    .homily-card {
        padding: 1rem !important;
    }

    .homily-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .homily-card-title {
        font-size: 1.1rem !important;
        word-break: break-word !important;
    }

    .homily-card-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    .homily-card-actions button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Filter Container */
    .homilies-filter-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .homilies-search {
        min-width: 100% !important;
        width: 100% !important;
    }

    .homilies-search input {
        width: 100% !important;
        font-size: 0.9rem !important;
        padding: 0.65rem 2.5rem 0.65rem 0.75rem !important;
    }

    .filter-options {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .filter-select {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Pagination */
    .pagination-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .pagination-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    .pagination-numbers {
        width: 100% !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
    }

    /* Action Buttons */
    .action-btn {
        font-size: 0.85rem !important;
        padding: 0.6rem 1rem !important;
        margin-right: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Sermon Ideas */
    .create-new-container {
        padding: 1rem !important;
        margin: 1rem 0 !important;
    }

    .create-new-btn {
        font-size: 1rem !important;
        padding: 0.85rem 1.5rem !important;
        width: 100% !important;
        justify-content: center !important;
    }

    .sermon-section {
        padding: 1rem !important;
    }

    .sermon-section h4 {
        font-size: 1.1rem !important;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1rem !important;
    }

    .form-group label {
        font-size: 0.9rem !important;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 0.9rem !important;
        padding: 0.65rem !important;
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 1rem !important;
        margin: 1rem !important;
    }

    .modal-header {
        padding: 1rem !important;
        flex-wrap: wrap !important;
    }

    .modal-header h4 {
        font-size: 1.2rem !important;
        word-break: break-word !important;
    }

    .modal form {
        padding: 1rem !important;
    }

    .modal-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .modal-actions button {
        width: 100% !important;
    }

    /* Review Form */
    .review-form {
        padding: 1rem !important;
    }

    .star-rating {
        font-size: 1.25rem !important;
    }

    .rating-text {
        font-size: 0.85rem !important;
        margin-left: 0.5rem !important;
    }

    /* Template Cards */
    .template-card {
        padding: 1rem !important;
    }

    .template-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .template-actions {
        width: 100% !important;
        flex-direction: column !important;
    }

    .template-actions .btn-small {
        width: 100% !important;
    }

    /* Support/Inquiry Items */
    .inquiry-item {
        padding: 1rem !important;
    }

    .inquiry-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }

    .inquiry-subject {
        font-size: 1rem !important;
        word-break: break-word !important;
    }

    .inquiry-meta {
        flex-direction: column !important;
        gap: 0.35rem !important;
        font-size: 0.85rem !important;
    }

    /* Chat Messages */
    .chat-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 85vh !important;
    }

    .chat-container {
        height: 350px !important;
    }

    .message-bubble {
        max-width: 85% !important;
        font-size: 0.9rem !important;
        padding: 0.65rem 0.85rem !important;
    }

    .chat-input-group textarea {
        font-size: 0.9rem !important;
        padding: 0.65rem 0.85rem !important;
    }

    /* Plan Info Bar */
    .plan-info-bar {
        padding: 0.75rem 1rem !important;
    }

    .plan-info-container {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: stretch !important;
    }

    .plan-info-item {
        justify-content: space-between !important;
        font-size: 0.85rem !important;
    }

    .plan-info-upgrade-btn {
        width: 100% !important;
        justify-content: center !important;
        margin-top: 0.5rem !important;
    }

    /* Footer */
    .dashboard-footer {
        padding: 1.5rem 1rem !important;
    }

    .dashboard-footer-links {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    /* Settings Section */
    .settings-form .form-group {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .setting-description {
        font-size: 0.85rem !important;
        margin-top: 0.35rem !important;
    }

    /* Current Plan Display */
    .current-plan {
        font-size: 0.9rem !important;
    }

    .current-plan p {
        margin-bottom: 0.75rem !important;
    }

    /* Upgrade Modal */
    .upgrade-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 1.5rem 1rem !important;
    }

    .plan-comparison {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .plan-card {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .plan-features {
        font-size: 0.85rem !important;
    }

    .plan-features li {
        padding: 0.4rem 0 !important;
    }

    /* Sidebar Footer */
    .sidebar-footer {
        padding: 1rem !important;
        font-size: 0.85rem !important;
    }

    .current-plan-info h4 {
        font-size: 0.95rem !important;
    }

    .update-plan-btn {
        font-size: 0.85rem !important;
        padding: 0.65rem !important;
    }
}

/* ============================================
   HOMILY VIEW PAGE MOBILE FIXES
   ============================================ */

@media (max-width: 768px) {
    /* Homily View Container */
    .homily-view-container {
        padding: 1rem !important;
        max-width: 100% !important;
    }

    /* Homily Details */
    .homily-details {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .homily-title {
        font-size: 1.4rem !important;
        word-break: break-word !important;
        margin-bottom: 1rem !important;
    }

    /* Title Edit */
    .title-edit-container {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .title-edit-form {
        width: 100% !important;
    }

    .title-edit-form input {
        width: 100% !important;
        font-size: 1rem !important;
        padding: 0.65rem !important;
    }

    .title-edit-button {
        font-size: 0.9rem !important;
    }

    /* Homily Meta */
    .homily-meta {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .meta-item {
        font-size: 0.85rem !important;
        word-break: break-word !important;
    }

    .meta-icon {
        font-size: 0.85rem !important;
    }

    .last-updated {
        font-size: 0.8rem !important;
    }

    /* Star Rating */
    .star-rating {
        gap: 0.2rem !important;
    }

    .star-rating i {
        font-size: 1.25rem !important;
    }

    .rating-text {
        font-size: 0.85rem !important;
        margin-left: 0.5rem !important;
    }

    /* Homily Content */
    .homily-content {
        padding: 1rem !important;
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }

    .homily-content p {
        margin-bottom: 1rem !important;
    }

    .homily-content h1,
    .homily-content h2,
    .homily-content h3,
    .homily-content h4,
    .homily-content h5,
    .homily-content h6 {
        word-break: break-word !important;
        margin-top: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .homily-content h1 { font-size: 1.5rem !important; }
    .homily-content h2 { font-size: 1.35rem !important; }
    .homily-content h3 { font-size: 1.2rem !important; }
    .homily-content h4 { font-size: 1.1rem !important; }

    /* Content Header Buttons */
    .homily-content-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    .content-header-buttons {
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .content-edit-button {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.65rem 1rem !important;
        font-size: 0.9rem !important;
    }

    /* Content Edit Form */
    .content-edit-form {
        margin-top: 1rem !important;
    }

    .content-edit-form textarea {
        width: 100% !important;
        font-size: 0.9rem !important;
        padding: 0.75rem !important;
        min-height: 300px !important;
    }

    .edit-form-buttons {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .edit-form-buttons button {
        width: 100% !important;
    }

    /* Homily Actions */
    .homily-actions {
        margin-top: 1.5rem !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .action-button {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.85rem 1.25rem !important;
        font-size: 0.95rem !important;
    }

    .action-button i {
        font-size: 1rem !important;
    }

    /* Share Modal */
    .modal-content {
        width: 90% !important;
        max-width: 90% !important;
        padding: 1.5rem 1rem !important;
    }

    .modal-content h2,
    .modal-content h3 {
        font-size: 1.3rem !important;
        word-break: break-word !important;
    }

    .share-options {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .share-option {
        padding: 1rem !important;
        font-size: 0.95rem !important;
    }

    .modal-close {
        font-size: 1.25rem !important;
    }

    /* Buttons */
    .btn-primary,
    .btn-outline {
        width: 100% !important;
        padding: 0.85rem 1.25rem !important;
        font-size: 0.95rem !important;
    }

    /* Loading Indicator */
    .loading-indicator {
        font-size: 0.85rem !important;
    }
}

/* ============================================
   EXTRA SMALL DEVICES (< 480px)
   ============================================ */

@media (max-width: 480px) {
    .dashboard-header .header-title h2 {
        font-size: 1rem !important;
    }

    .homily-title {
        font-size: 1.2rem !important;
    }

    .homily-content {
        font-size: 0.9rem !important;
        padding: 0.85rem !important;
    }

    .homily-content h1 { font-size: 1.3rem !important; }
    .homily-content h2 { font-size: 1.2rem !important; }
    .homily-content h3 { font-size: 1.1rem !important; }

    .action-button {
        font-size: 0.9rem !important;
        padding: 0.75rem 1rem !important;
    }

    .modal-content {
        width: 95% !important;
        padding: 1rem 0.75rem !important;
    }

    .referral-link {
        font-size: 0.85rem !important;
        padding: 0.65rem 1rem !important;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Full width on mobile */
    .mobile-full-width {
        width: 100% !important;
    }

    /* Prevent horizontal overflow */
    body,
    html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    * {
        max-width: 100% !important;
    }

    /* Fix for tables */
    table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    /* Fix for pre/code blocks */
    pre,
    code {
        overflow-x: auto !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
    }
}

/* ============================================
   BILLING PAGE MOBILE FIXES
   ============================================ */

@media (max-width: 768px) {
    .billing-container {
        margin: 1rem !important;
        padding: 1rem !important;
    }

    .billing-header {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: flex-start !important;
    }

    .billing-header h1 {
        font-size: 1.5rem !important;
    }

    .subscription-info {
        padding: 1rem !important;
    }

    .plan-details {
        flex-direction: column !important;
    }

    .plan-detail {
        flex-basis: 100% !important;
        margin-bottom: 0.75rem !important;
    }

    .upgrade-btn {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        margin-top: 0.5rem !important;
    }

    .invoices-section h2 {
        font-size: 1.3rem !important;
    }

    /* Make table responsive */
    .invoices-table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .invoices-table thead {
        display: none !important;
    }

    .invoices-table tbody {
        display: block !important;
    }

    .invoices-table tr {
        display: block !important;
        margin-bottom: 1rem !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        padding: 1rem !important;
        background: #fff !important;
    }

    .invoices-table td {
        display: block !important;
        text-align: left !important;
        padding: 0.5rem 0 !important;
        border: none !important;
    }

    .invoices-table td:before {
        content: attr(data-label) !important;
        font-weight: bold !important;
        display: inline-block !important;
        width: 120px !important;
        margin-right: 1rem !important;
        color: #666 !important;
    }

    .download-btn,
    .view-btn {
        width: 100% !important;
        margin-top: 0.5rem !important;
        padding: 0.65rem 1rem !important;
    }

    .payment-method {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .payment-method-details,
    .payment-method-actions {
        width: 100% !important;
    }

    .update-payment-btn {
        width: 100% !important;
    }
}

/* ============================================
   REFER AND EARN PAGE MOBILE FIXES
   ============================================ */

@media (max-width: 768px) {
    .affiliate-hero {
        padding: 1.5rem 1rem !important;
    }

    .affiliate-hero h1 {
        font-size: 1.5rem !important;
    }

    .affiliate-hero p {
        font-size: 0.95rem !important;
    }

    .earnings-card {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .earnings-card h2 {
        font-size: 1.8rem !important;
    }

    .earnings-card p {
        font-size: 0.9rem !important;
    }

    .stats-card {
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
    }

    .stats-card h3 {
        font-size: 1.8rem !important;
    }

    .stats-card p {
        font-size: 0.85rem !important;
    }

    .commission-badge {
        font-size: 0.8rem !important;
        padding: 4px 12px !important;
    }

    /* Navigation Tabs */
    .nav-tabs {
        flex-direction: column !important;
        padding: 0.5rem !important;
    }

    .nav-tabs .nav-link {
        width: 100% !important;
        text-align: center !important;
        padding: 0.75rem !important;
        font-size: 1rem !important;
        border-bottom: 1px solid #dee2e6 !important;
    }

    .nav-tabs .nav-link.active {
        background-color: #e9ecef !important;
        border-radius: 4px !important;
    }

    /* Referral Link Section */
    .referral-link-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .referral-link-input {
        width: 100% !important;
        font-size: 0.85rem !important;
        padding: 0.75rem !important;
    }

    .copy-button {
        width: 100% !important;
        padding: 0.75rem 1.25rem !important;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Referrals Table */
    .referrals-table {
        display: block !important;
        overflow-x: auto !important;
    }

    .referrals-table thead {
        display: none !important;
    }

    .referrals-table tbody {
        display: block !important;
    }

    .referrals-table tr {
        display: block !important;
        margin-bottom: 1rem !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        padding: 1rem !important;
    }

    .referrals-table td {
        display: block !important;
        text-align: left !important;
        padding: 0.5rem 0 !important;
        border: none !important;
    }

    .referrals-table td:before {
        content: attr(data-label) !important;
        font-weight: bold !important;
        display: inline-block !important;
        width: 100px !important;
        margin-right: 1rem !important;
    }

    /* Bank Details Form */
    .bank-details-form .form-group {
        margin-bottom: 1rem !important;
    }

    .bank-details-form input,
    .bank-details-form select {
        font-size: 0.9rem !important;
        padding: 0.65rem !important;
    }

    .bank-details-form button {
        width: 100% !important;
        padding: 0.85rem !important;
    }

    /* How It Works Section */
    .how-it-works-steps {
        grid-template-columns: 1fr !important;
    }

    .step-card {
        margin-bottom: 1rem !important;
    }

    /* Withdraw Button */
    .withdraw-btn {
        width: 100% !important;
        padding: 0.85rem 1.25rem !important;
    }
}

/* ============================================
   SUPPORT TABS MOBILE FIXES (Dashboard)
   ============================================ */

@media (max-width: 768px) {
    /* Support Tabs - Make them horizontal and button-like */
    .support-tabs {
        display: flex !important;
        flex-direction: row !important;
        border-bottom: none !important;
        gap: 0.5rem !important;
        padding: 0 !important;
        margin-bottom: 1.5rem !important;
        background: transparent !important;
    }

    .support-tab {
        flex: 1 !important;
        padding: 0.85rem 1rem !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        border: 2px solid #4e81bc !important;
        border-radius: 8px !important;
        background-color: white !important;
        color: #4e81bc !important;
        text-align: center !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }

    .support-tab:hover {
        background-color: #f0f6ff !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15) !important;
    }

    .support-tab.active {
        background-color: #4e81bc !important;
        color: white !important;
        border-color: #2a6b9d !important;
        box-shadow: 0 3px 8px rgba(78, 129, 188, 0.4) !important;
    }

    /* Remove the border-bottom active indicator on mobile */
    .support-tab {
        border-bottom: 2px solid #4e81bc !important;
    }

    .support-tab.active {
        border-bottom: 2px solid #2a6b9d !important;
    }
}

@media (max-width: 480px) {
    /* Stack tabs vertically on very small screens */
    .support-tabs {
        flex-direction: column !important;
    }

    .support-tab {
        width: 100% !important;
    }
}
