/* Mobile Optimization CSS */

/* Base mobile styles */
@media screen and (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.4;
    }

    /* Header mobile optimization */
    .header {
        padding: 10px 15px;
        flex-wrap: wrap;
    }

    .nav-container {
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .header .logo {
        font-size: 20px;
        margin-bottom: 10px;
        width: 100%;
        text-align: center;
    }

    .header .search-bar {
        width: 100% !important;
        margin: 10px 0 !important;
        order: 3 !important;
        max-width: none !important;
        align-self: stretch !important;
    }

    .header .search-bar input {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 15px;
        width: 100%;
    }

    .header .nav-actions {
        width: 100% !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        margin-top: 10px !important;
        flex-wrap: nowrap !important;
        align-self: stretch !important;
    }

    .header .nav-actions .btn {
        padding: 8px 16px !important;
        font-size: 14px !important;
        min-width: 80px !important;
    }

    /* Ensure header action button doesn't stretch full width on mobile */
    .header .nav-actions .btn-primary {
        flex: 1 1 auto !important;
        width: auto !important;
        padding: 10px 18px !important;
        font-size: 16px !important;
        border-radius: 24px !important;
        display: inline-flex !important;
        align-items: center !important;
        margin-right: 12px !important;
    }

    /* Avatar à direita do header */
    .header .nav-actions .user-menu {
        margin-left: auto !important;
        flex: 0 0 auto !important;
    }

    /* Avatar alinhado visualmente ao centro e à direita */
    .header .user-menu .user-avatar {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
    }

    .user-menu {
        position: relative;
    }

    .user-dropdown {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        bottom: auto !important;
        transform: none !important;
        width: 280px !important;
        max-width: 90vw !important;
        z-index: 1000 !important;
    }

    /* Container and layout mobile optimization */
    .main-container {
        padding: 5px;
        margin: 0rem !important;
    }

    .container {
        padding: 0 10px;
        margin: 0;
        max-width: 100%;
    }

    .create-form {
        margin: 10px 0;
        padding: 15px;
        border-radius: 12px;
    }

    .platforms-grid {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .platform-item {
        width: 100%;
        max-width: 280px;
        justify-content: center;
        padding: 12px;
    }

    /* Welcome section mobile */
    .welcome-section {
        text-align: center;
        margin-bottom: 0 !important;
    }

    .welcome-section h1 {
        font-size: 24px;
    }

    .welcome-section p {
        font-size: 16px;
        margin-bottom: 20px;
    }

    /* Posts grid mobile optimization */
    .posts-grid {
        padding: 15px;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .post-card {
        margin-bottom: 15px;
        border-radius: 12px;
    }

    .post-card .post-image {
        height: 200px;
        border-radius: 12px 12px 0 0;
    }

    .post-card .post-content {
        padding: 15px;
    }

    .post-card .post-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .post-card .post-description {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .post-card .post-actions {
        gap: 15px;
    }

    .post-card .post-actions button {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Forms mobile optimization */
    .form-container {
        padding: 20px 15px;
        margin: 20px 10px;
        border-radius: 12px;
    }

    .form-container h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 20px;
    }

    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 15px;
        border-radius: 8px;
    }

    .form-group textarea {
        min-height: 100px;
        resize: vertical;
    }

    /* Largura total deve se aplicar apenas a botões em áreas de formulário */
    .form-container .btn-primary,
    .create-form .btn-primary,
    .form-actions .btn-primary,
    .platforms-grid .btn-primary,
    .form-group .btn-primary {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        border-radius: 8px;
        margin-top: 10px;
    }

    /* Comments section mobile */
    .comments-section {
        padding: 15px;
    }

    .comment-item {
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .comment-author {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 5px;
    }

    .comment-text {
        font-size: 14px;
        line-height: 1.4;
        margin-bottom: 8px;
    }

    .comment-actions {
        gap: 10px;
    }

    .comment-actions button {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* Modal mobile optimization */
    .modal-content {
        margin: 20px;
        padding: 20px;
        border-radius: 12px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }

    .modal-header {
        padding-bottom: 15px;
    }

    .modal-body {
        padding: 0;
    }

    .modal-footer {
        padding-top: 15px;
        margin-top: 15px;
        flex-direction: column;
        gap: 10px;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .posts-grid {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 3px;
    }

    .post-card .post-image {
        height: 180px;
    }

    .header .user-actions {
        flex-direction: column;
        gap: 10px;
    }

    .header .user-actions .btn {
        width: 100%;
        max-width: 200px;
    }

    .form-container {
        margin: 10px 5px;
        padding: 15px;
    }

    .welcome-section h1 {
        font-size: 20px;
    }

    .welcome-section p {
        font-size: 14px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    .btn,
    button,
    .post-card,
    .comment-item {
        min-height: 22px;
        /* Apple's recommended touch target size */
    }

    .post-actions button,
    .comment-actions button {
        min-height: 40px;
        min-width: 40px;
    }

    /* Increase spacing for touch targets */
    .post-actions {
        gap: 20px;
    }

    .comment-actions {
        gap: 15px;
    }
}

/* Landscape orientation on mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 8px 15px;
    }

    .header .logo {
        font-size: 18px;
        margin-bottom: 5px;
    }

    .welcome-section {
        padding: 15px;
    }

    .welcome-section h1 {
        font-size: 22px;
    }

    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .post-card .post-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #ffffff;
    }

    .header {
        background-color: #1e1e1e;
        border-bottom-color: #333;
    }

    .post-card {
        background-color: #1e1e1e;
        border-color: #333;
    }

    .form-container {
        background-color: #1e1e1e;
        border-color: #333;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        background-color: #2a2a2a;
        border-color: #444;
        color: #ffffff;
    }

    .btn-primary {
        background-color: #0066cc;
    }

    .btn-secondary {
        background-color: #444;
        color: #ffffff;
    }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Supported Platforms Section */
.supported-platforms {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid #e9ecef;
}

.supported-platforms h3 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.platforms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.platform-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.platform-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.platform-item.active {
    border-color: #007bff;
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.platform-item i {
    font-size: 1.2rem;
}

.platform-item span {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Preview Container */
.preview-container {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.preview-container h3 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.link-preview {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.preview-header i {
    font-size: 1.1rem;
}

.platform-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.preview-image {
    position: relative;
    max-height: 200px;
    overflow: hidden;
}

.preview-image img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-content {
    padding: 15px;
}

.preview-title {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.4;
}

.preview-description {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading and Error States */
.loading-preview,
.error-preview {
    padding: 30px;
    text-align: center;
    color: #6c757d;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-preview i {
    font-size: 2rem;
    color: #dc3545;
    margin-bottom: 10px;
    display: block;
}

/* Form Enhancements */
.form-help {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
}

.form-group input.error,
.form-group textarea.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Alert Styles */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Mobile Optimizations for Preview */
@media (max-width: 768px) {
    .platforms-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .platform-item {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .platform-item i {
        font-size: 1rem;
    }

    .preview-container {
        padding: 15px;
        margin-top: 20px;
    }

    .preview-image {
        max-height: 150px;
    }

    .preview-content {
        padding: 12px;
    }

    .preview-title {
        font-size: 0.95rem;
    }

    .preview-description {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .platforms-grid {
        grid-template-columns: 1fr;
    }

    .platform-item {
        justify-content: center;
    }
}