/* Mobile-Specific Optimizations for All Device Sizes (index.php and dashboard.php) */

/* Apply styles for mobile devices (max-width: 767px) */
@media (max-width: 767px) {
    /* Reset and Base Styles for Mobile */
    * {
        -webkit-tap-highlight-color: transparent; /* Prevent tap highlight on mobile */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    body {
        font-size: 16px; /* Base font size for better readability on mobile */
        line-height: 1.5; /* Slightly tighter line-height for mobile */
    }
    /* Starry/Wave Background */
    #stars-background, #shooting-stars, #stars-background-support, #shooting-stars-support,
    #dashboard-stars-background, #dashboard-shooting-stars {
        will-change: transform; /* Optimize for mobile rendering */
        z-index: 0; /* Ensure background stays behind content */
    }
    /* Header Styles (applies to index.php and dashboard.php) */
    .header {
        height: 3.5rem; /* Reduced height for mobile */
        padding: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: center; /* Center content in header */
    }
    .header .max-w-7xl {
        padding: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between; /* Space for logo and hamburger */
        width: 100%;
        position: relative;
    }
    .header .logo.logo-mobile {
        display: inline-flex;
        align-items: center;
        position: absolute;
        left: 50%;
        transform: translateX(-50%); /* Center logo horizontally */
        z-index: 10; /* Above other elements */
    }
    .header .logo.logo-mobile img {
        height: 3rem; /* Smaller logo for mobile */
        width: auto;
    }
    .header .logo.logo-desktop {
        display: none; /* Hide desktop logo on mobile */
    }
    .header nav {
        display: none; /* Hide nav by default on mobile */
        position: absolute;
        top: 3.5rem;
        left: 0;
        width: 100%;
        background: #ffffff; /* Match header background */
        padding: 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        flex-direction: column; /* Stack nav items vertically */
        gap: 0.25rem;
        align-items: flex-start; /* Align nav items to the start */
        z-index: 5; /* Below logo but above background */
    }
    .header nav.active {
        display: flex; /* Show nav when hamburger is toggled */
    }
    .header .hamburger {
        display: block;
        font-size: 1.5rem;
        cursor: pointer;
        color: #1E3A8A;
        padding: 0.25rem;
        line-height: 1; /* Ensure hamburger icon aligns properly */
        margin-left: auto; /* Push hamburger to the right */
        z-index: 10; /* Ensure hamburger is clickable */
    }
    .header nav a {
        font-size: 0.85rem; /* Smaller font size for mobile */
        padding: 0.4rem 0.8rem;
        width: 100%; /* Full width for touch targets */
        text-align: left; /* Align text for better readability */
    }
    /* Homepage and Content Container */
    .homepage {
        padding-top: 3.5rem; /* Adjust for smaller header */
    }
    .content-container {
        padding: 0 0.5rem;
    }
    /* Hero Section */
    .hero {
        min-height: 80vh;
        padding: 1rem 0.5rem;
    }
    .hero-logo {
        max-width: 200px;
        width: 60%;
    }
    .hero-content {
        padding: 0 0.5rem;
    }
    .hero-content h1 {
        font-size: 1.8rem;
        margin-bottom: 0.75rem;
    }
    .hero-content p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    .cta-button, #join-team-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    /* Our Mission Section */
    .our-mission {
        padding: 1.5rem 0.5rem;
    }
    .our-mission h2 {
        font-size: 1.6rem;
    }
    .our-mission p {
        font-size: 0.9rem;
    }
    .our-mission .mission-card {
        padding: 1rem;
    }
    /* Features Section */
    .features {
        padding: 1.5rem 0.5rem;
    }
    .features h2 {
        font-size: 1.6rem;
    }
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 0.5rem;
    }
    .feature-card {
        padding: 1rem;
    }
    .feature-card h3 {
        font-size: 1.1rem;
    }
    .feature-card p {
        font-size: 0.85rem;
    }
    /* FAQ Section */
    .faq-container {
        padding: 0.75rem;
    }
    .faq-container h2 {
        font-size: 1.3rem;
    }
    .faq-tab-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    .faq-tab-content {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    .faq-tab-content:not(.hidden) {
        max-height: 300px;
    }
    /* Contact Section */
    #contact .content-container {
        padding: 1.5rem 0.5rem;
        flex-direction: column;
        gap: 2rem;
    }
    .contact-flip-card {
        min-height: 350px;
        padding: 1rem;
    }
    .contact-flip-card h2 {
        font-size: 1.3rem;
    }
    .contact-form .form-group label {
        font-size: 0.6rem;
    }
    .contact-form .form-group select,
    .contact-form .form-group input,
    .contact-form .form-group textarea {
        font-size: 0.6rem;
        padding: 0.2rem;
    }
    .contact-form .btn {
        font-size: 0.6rem;
        padding: 0.2rem;
        max-width: calc(100% - 1rem);
        margin: 0.5rem;
    }
    /* Support Section */
    .support-section {
        padding: 1.5rem 0.5rem; /* Reduced padding to fit content */
        display: flex;
        flex-direction: column;
        align-items: center; /* Center content horizontally */
        overflow: visible; /* Prevent content clipping */
        box-sizing: border-box;
        width: 100%; /* Ensure full viewport width */
        position: relative;
        z-index: 1; /* Above wave background */
    }
    .support-section .content-container {
        max-width: 100%; /* Prevent overflow */
        padding: 0 0.5rem;
        display: flex;
        flex-direction: column;
        align-items: center; /* Center content within container */
        justify-content: center;
        box-sizing: border-box;
        z-index: 2; /* Above wave background */
    }
    .support-title {
        font-size: 1.6rem; /* Slightly smaller for mobile */
        margin-bottom: 0.75rem;
        text-align: center;
        z-index: 3; /* Above wave background */
    }
    .support-description {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        max-width: 100%; /* Ensure description fits viewport */
        text-align: center;
        z-index: 3; /* Above wave background */
    }
    .support-goal-container {
        display: flex;
        flex-direction: column; /* Stack heart and text vertically */
        align-items: center; /* Center horizontally */
        justify-content: center;
        width: 100%;
        margin-bottom: 1rem;
        z-index: 3; /* Above wave background */
    }
    .support-goal-container .heart-wrap {
        margin: 0 auto; /* Center the heart */
        display: flex;
        justify-content: center;
        align-items: center;
        width: 80px; /* Match heart dimensions */
        height: 70px;
        z-index: 3; /* Above wave background */
    }
    .heart {
        margin: 0 auto; /* Ensure heart is centered */
        width: var(--dim-x);
        height: var(--dim-y);
        z-index: 3; /* Above wave background */
    }
    .support-goal-container .goal-text {
        font-size: 0.8rem;
        text-align: center;
        margin-top: 0.5rem;
        max-width: 100%; /* Prevent text overflow */
        z-index: 3; /* Above wave background */
        position: relative; /* Ensure text is positioned correctly */
    }
    .support-options {
        flex-direction: column; /* Stack buttons vertically */
        gap: 0.5rem;
        width: 100%; /* Full width for buttons */
        max-width: 300px; /* Limit button width for balance */
        margin: 0 auto; /* Center buttons */
        z-index: 3; /* Above wave background */
    }
    .support-options .support-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        width: 100%; /* Full width for touch targets */
        text-align: center;
        box-sizing: border-box;
        z-index: 3; /* Above wave background */
    }
    /* Sponsors Section */
    .sponsors-section {
        padding: 1.5rem 0.5rem;
        z-index: 1; /* Above wave background */
    }
    .sponsors-section h2 {
        font-size: 1.6rem;
    }
    .sponsor-grid {
        gap: 2rem;
        width: 2000px;
        animation: slide 20s linear infinite;
    }
    .sponsor-img {
        width: 120px;
        height: 80px;
    }
    @keyframes slide {
        0% {
            transform: translateX(0);
        }
        100% {
            transform: translateX(-1000px);
        }
    }
    /* Progress Circle */
    .progress-circle-container {
        width: 120px;
        height: 120px;
        z-index: 3; /* Above wave background */
    }
    .progress-percentage {
        font-size: 1.5rem;
    }
    .progress-goal {
        font-size: 0.75rem;
    }
    /* Dashboard Styles */
    .dashboard {
        padding-top: 3.5rem;
        flex-direction: column;
    }
    .sidebar {
        margin: 0.5rem;
        height: auto;
        padding: 0.75rem;
    }
    .profile-pic {
        width: 3rem;
        height: 3rem;
    }
    .sidebar h2 {
        font-size: 1rem;
    }
    .sidebar p {
        font-size: 0.7rem;
    }
    .main-content {
        padding: 0.75rem 0.5rem;
    }
    .main-content h1 {
        font-size: 1.3rem;
    }
    .card {
        padding: 1rem;
    }
    .card h2 {
        font-size: 1.1rem;
    }
    .card h3 {
        font-size: 0.9rem;
    }
    .card p {
        font-size: 0.8rem;
    }
    /* Notebook-Style Tabs */
    .tab-nav nav {
        flex-direction: column;
    }
    .tab-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
        border-bottom: none;
        border-right: 2px solid transparent;
    }
    .tab-link:hover {
        border-bottom: none;
        border-right: 2px solid #93c5fd;
        background: rgba(30, 58, 138, 0.8);
        color: #ffffff;
    }
    .tab-link.tab-active {
        border-bottom: none;
        border-right: 2px solid #1E3A8A;
        background: rgba(30, 58, 138, 0.8);
        color: #ffffff;
    }
    /* Form and Button Styles */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
    .form-group.name-group .name-inputs {
        grid-template-columns: 1fr;
    }
    button, .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    /* Password Strength Meter */
    #password-strength {
        margin-bottom: 1rem;
    }
    /* Journal Section */
    #journal-section {
        padding: 0.5rem;
    }
    .journal-toggle {
        font-size: 0.8rem;
    }
    #journal-entries > div {
        padding: 0.4rem;
    }
    #journal-entries span.text-sm {
        font-size: 0.8rem;
    }
    #journal-entries .text-gray-500,
    #journal-entries .text-gray-400 {
        font-size: 0.7rem;
    }
    #journal-search,
    #journal-filter {
        font-size: 0.8rem;
        padding: 0.2rem;
    }
    /* Social Section */
    .social-subsection {
        padding: 0.5rem;
    }
    .social-tab-link {
        padding: 6px 12px;
        font-size: 0.75rem; /* Smaller text for mobile */
        border-radius: 4px;
    }
    .mt-3.space-x-2.mb-4 {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    #posts-list .bg-white,
    #friends-list .flex,
    #user-list .flex,
    #conversations-list .flex {
        padding: 10px;
        margin-bottom: 12px;
    }
    #posts-list img.rounded-full {
        width: 32px;
        height: 32px;
    }
    #posts-list .post-content {
        font-size: 0.8125rem; /* Slightly smaller than desktop */
        padding: 6px 0;
    }
    .post-actions {
        gap: 6px; /* Tighter spacing for mobile */
        justify-content: flex-start;
        flex-wrap: wrap; /* Allow wrapping for many buttons */
    }
    .post-actions .btn {
        padding: 3px 6px;
        font-size: 0.6875rem; /* Smaller than text-xs */
        border-radius: 4px;
        display: flex;
        align-items: center;
        gap: 4px; /* Space for icons */
    }
    .post-actions .btn i {
        font-size: 0.6875rem; /* Match button text */
    }
    .post-actions .edit-btn {
        background-color: #123084;
    }
    .post-actions .edit-btn:hover {
        background-color: #4B61A1;
    }
    .post-actions .delete-btn {
        background-color: #dc2626;
    }
    .post-actions .delete-btn:hover {
        background-color: #ef4444;
    }
    .post-actions .like-btn {
        background-color: #6b7280; /* Gray-500 for unliked */
    }
    .post-actions .like-btn.bg-blue-600 {
        background-color: #2563eb; /* Blue-600 for liked */
    }
    .post-actions .like-btn:hover {
        background-color: #9ca3af; /* Gray-400 for unliked hover */
    }
    .post-actions .like-btn.bg-blue-600:hover {
        background-color: #1d4ed8; /* Blue-700 for liked hover */
    }
    .post-actions .share-btn {
        background-color: #6b7280; /* Gray-500 */
    }
    .post-actions .share-btn:hover {
        background-color: #9ca3af; /* Gray-400 */
    }
    .post-actions .unshare-btn {
        background-color: #dc2626; /* Red-600 */
    }
    .post-actions .unshare-btn:hover {
        background-color: #ef4444; /* Red-500 */
    }
    .post-actions .reply-btn {
        background-color: #059669; /* Emerald-600 */
    }
    .post-actions .reply-btn:hover {
        background-color: #047857; /* Emerald-700 */
    }
    .reply-form {
        padding: 6px;
        margin-top: 6px;
    }
    .reply-form textarea {
        font-size: 0.8125rem;
        padding: 6px;
        min-height: 50px;
    }
    .reply-form .btn {
        padding: 3px 6px;
        font-size: 0.6875rem;
    }
    .reply-form .submit-reply-btn {
        background-color: #123084;
    }
    .reply-form .submit-reply-btn:hover {
        background-color: #4B61A1;
    }
    .reply-form .cancel-reply-btn {
        background-color: #6b7280;
    }
    .reply-form .cancel-reply-btn:hover {
        background-color: #9ca3af;
    }
    .replies {
        padding-left: 12px; /* Smaller indent */
        border-left: 1px solid #e5e7eb; /* Thinner border */
    }
    .replies .reply {
        padding: 6px;
        margin-bottom: 6px;
    }
    .replies img.rounded-full {
        width: 28px;
        height: 28px;
    }
    .replies .text-gray-700 {
        font-size: 0.75rem; /* Smaller text for replies */
    }
    #create-post-form textarea {
        font-size: 0.875rem;
        padding: 8px;
        min-height: 100px;
    }
    #create-post-form .btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    .post-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    .reply-item {
        padding: 6px;
        margin-bottom: 6px;
    }
    /* Admin Section */
    #admin-section {
        padding: 0.5rem;
    }
    .admin-subsection th,
    .admin-subsection td {
        font-size: 0.7rem;
        padding: 0.4rem;
    }
    .admin-tab-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    /* Modal Styles */
    .modal-content {
        padding: 1rem;
        max-width: 90%;
    }
    .modal-content h2 {
        font-size: 1.3rem;
    }
    .modal-content h3 {
        font-size: 1rem;
    }
    .modal-content button {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    #delete-account-modal .modal-content {
        padding: 1rem;
    }
    #delete-account-modal .modal-content input#delete-confirm-input {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
    #delete-account-modal .modal-content button#delete-confirm,
    #delete-account-modal .modal-content button#delete-cancel {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    /* Footer Styles */
    .footer {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    .quick-links {
        flex-direction: column;
        gap: 0.5rem;
    }
    .social-icons {
        gap: 1rem;
    }
    .social-icon {
        font-size: 1.2rem;
    }
    /* Back to Top */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2rem;
        height: 2rem;
    }
    .back-to-top svg {
        width: 1.2rem;
        height: 1.2rem;
    }
    /* Messages Section */
    #messages-list .message.sent,
    #messages-list .message.received {
        margin-left: 10%;
        margin-right: 10%;
    }
    #messages-list {
        max-height: 200px; /* Smaller height for mobile */
    }
    #messages-list .bg-blue-100,
    #messages-list .bg-gray-100 {
        max-width: 85%; /* Wider messages */
        padding: 6px;
    }
    .message-form {
        flex-direction: column;
        align-items: stretch;
    }
    .message-form .btn {
        width: 100%;
        text-align: center;
        padding: 3px 6px;
        font-size: 0.6875rem;
    }
    .message-form textarea {
        font-size: 0.8125rem;
        padding: 6px;
        min-height: 50px;
    }
    .message-form .send-btn {
        background-color: #123084;
    }
    .message-form .send-btn:hover {
        background-color: #4B61A1;
    }
    /* Profile Details */
    .profile-details img.rounded-full {
        width: 60px;
        height: 60px;
    }
    .profile-details .flex.space-x-2 {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* Extra Small Devices (below 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    .header {
        height: 3rem;
    }
    .header .logo.logo-mobile img {
        height: 2.5rem;
    }
    .header nav {
        top: 3rem;
    }
    .hero-logo {
        max-width: 150px;
        width: 50%;
    }
    .hero-content h1 {
        font-size: 1.5rem;
    }
    .hero-content p {
        font-size: 0.85rem;
    }
    .support-section {
        padding: 1rem 0.25rem; /* Further reduced padding */
    }
    .support-title {
        font-size: 1.4rem;
    }
    .support-description {
        font-size: 0.85rem;
    }
    .support-goal-container .heart-wrap {
        width: 60px; /* Smaller heart for tiny screens */
        height: 50px;
    }
    .heart {
        width: 60px;
        height: 50px;
    }
    .support-goal-container .goal-text {
        font-size: 0.75rem;
    }
    .support-options .support-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    .sponsor-img {
        width: 100px;
        height: 60px;
    }
    .progress-circle-container {
        width: 100px;
        height: 100px;
    }
    .progress-percentage {
        font-size: 1.2rem;
    }
    .progress-goal {
        font-size: 0.7rem;
    }
    /* Social Section */
    .social-tab-link {
        padding: 5px 10px;
        font-size: 0.6875rem;
    }
    #posts-list .bg-white {
        padding: 8px;
        margin-bottom: 10px;
    }
    #posts-list img.rounded-full {
        width: 28px;
        height: 28px;
    }
    #posts-list .post-content {
        font-size: 0.75rem;
        padding: 4px 0;
    }
    .post-actions {
        gap: 4px;
    }
    .post-actions .btn {
        padding: 2px 5px;
        font-size: 0.625rem;
        gap: 3px;
    }
    .post-actions .btn i {
        font-size: 0.625rem;
    }
    .reply-form {
        padding: 4px;
        margin-top: 4px;
    }
    .reply-form textarea {
        font-size: 0.75rem;
        padding: 4px;
        min-height: 40px;
    }
    .reply-form .btn {
        padding: 2px 5px;
        font-size: 0.625rem;
    }
    .replies {
        padding-left: 8px;
        border-left: 1px solid #e5e7eb;
    }
    .replies .reply {
        padding: 4px;
        margin-bottom: 4px;
    }
    .replies img.rounded-full {
        width: 24px;
        height: 24px;
    }
    .replies .text-gray-700 {
        font-size: 0.6875rem;
    }
    #create-post-form textarea {
        font-size: 0.8125rem;
        padding: 6px;
        min-height: 60px;
    }
    #create-post-form .btn {
        padding: 4px 10px;
        font-size: 0.6875rem;
    }
}

/* Desktop Styles (min-width: 768px) */
@media (min-width: 768px) {
    .content-container {
        padding: 0 1rem;
    }
    .hero {
        padding: 2rem 1rem;
    }
    .hero-content {
        padding: 0 1rem;
    }
    .our-mission {
        padding: 2.5rem 1rem;
    }
    .features {
        padding: 2.5rem 1rem;
    }
    .feature-grid {
        padding: 0 1rem;
    }
    #contact .content-container {
        padding: 2.5rem 1rem;
        flex-direction: row;
    }
    .sponsors-section {
        padding: 2.5rem 1rem;
    }
    .dashboard {
        flex-direction: row;
    }
    .sidebar {
        width: 25%;
        margin: 1rem;
    }
    .main-content {
        width: 75%;
        padding: 1.5rem 1rem;
    }
    .header .logo.logo-mobile {
        display: none !important; /* Hide mobile logo on desktop */
    }
    .header .logo.logo-desktop {
        display: inline-flex; /* Show desktop logo */
        align-items: center;
    }
    .header .hamburger {
        display: none; /* Hide hamburger on desktop */
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .back-to-top,
    .modal,
    #stars-background,
    #shooting-stars,
    #dashboard-stars-background,
    #dashboard-shooting-stars {
        display: none;
    }
    body {
        background: #ffffff;
        color: #000000;
    }
    .section,
    .card,
    .tab-content,
    .contact-flip-card-back {
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
    .contact-flip-card {
        perspective: none;
    }
    .contact-flip-card-inner {
        transform: none;
    }
    .contact-flip-card-front {
        display: none;
    }
    .contact-flip-card-back {
        transform: none;
        position: static;
    }
    .btn,
    .cta-button,
    .support-btn {
        border: 1px solid #000000;
        color: #000000;
        background: none;
    }
    .no-print {
        display: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    body {
        background: #000000;
        color: #ffffff;
    }
    .header,
    .section,
    .card,
    .tab-content,
    .contact-flip-card-back {
        background: #000000;
        color: #ffffff;
        border: 1px solid #ffffff;
    }
    .btn,
    .cta-button,
    .support-btn {
        border: 2px solid #ffffff;
        color: #ffffff;
        background: #000000;
    }
    .btn:hover,
    .cta-button:hover,
    .support-btn:hover {
        background: #ffffff;
        color: #000000;
    }
    a {
        color: #ffffff;
        text-decoration: underline;
    }
    a:hover {
        color: #e5e7eb;
    }
}