/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Noto Sans Georgian', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    overflow: hidden;
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-weight: 700;
}

.tagline {
    color: #666;
    font-size: 1rem;
    font-weight: 500;
}

/* Post Form */
.post-form {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    max-width: 100%;
    overflow: hidden;
}

.post-form input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    margin-bottom: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
}

.post-form textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 100px;
    resize: vertical;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
}

.post-form input:focus,
.post-form textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

#char-count {
    color: #888;
    font-size: 0.85rem;
}

#post-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#post-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#post-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-message {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 30px;
}

.feed-section {
    flex: 1;
    min-width: 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid transparent;
    padding: 14px 24px;
    min-height: 48px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    -webkit-user-select: none;
    user-select: none;
}

.tab:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

.tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Feed */
.feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Complaint Card */
.complaint-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.complaint-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.complaint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.complaint-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.complaint-author {
    font-weight: 600;
    color: #333;
}

.complaint-time {
    color: #888;
    font-size: 0.85rem;
}

.social-share-icons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.share-icon-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
}

.share-icon-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.share-icon-btn svg {
    display: block;
}

.complaint-text {
    font-size: 1rem;
    color: #444;
    margin-bottom: 15px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    max-width: 100%;
}

/* Reactions Bar */
.reactions-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.reaction-btn {
    background: transparent;
    border: none;
    padding: 10px 12px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0.5;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
}

.reaction-btn:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.15);
}

.reaction-btn.active {
    opacity: 1;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.reaction-btn.report-icon {
    font-size: 0.85rem;
    opacity: 0.3;
    padding: 4px 8px;
}

.reaction-btn.report-icon:hover {
    opacity: 0.6;
}

.reaction-btn.reported {
    opacity: 0.2;
    cursor: not-allowed;
}

.reactions-count {
    font-size: 0.75rem;
    color: #999;
    font-weight: 500;
    margin-left: 4px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

/* Actions Bar */
.actions-bar {
    display: flex;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    align-items: center;
}

.action-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
}

.action-btn:hover {
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
}

.action-btn .action-icon {
    font-size: 1rem;
    opacity: 0.7;
}

.action-btn .action-count {
    font-size: 0.8rem;
    color: #667eea;
    font-weight: 600;
}

.action-btn.report-btn {
    opacity: 0.4;
    padding: 6px 10px;
}

.action-btn.report-btn:hover {
    opacity: 0.7;
    background: rgba(220, 53, 69, 0.08);
}

.action-btn.reported {
    color: #dc3545;
    opacity: 0.3;
    cursor: not-allowed;
}

/* Comments Preview */
.comments-preview {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.comment-item {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.comment-author {
    font-weight: 500;
    font-size: 0.9rem;
}

.comment-time {
    color: #888;
    font-size: 0.8rem;
}

.comment-text {
    font-size: 0.9rem;
    color: #555;
}

.comment-reactions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    align-items: center;
}

.comment-reactions .reaction-btn {
    padding: 4px 8px;
    font-size: 0.95rem;
    opacity: 0.4;
}

.comment-reactions .reaction-btn:hover {
    opacity: 0.8;
}

.comment-reactions .reaction-btn.active {
    opacity: 1;
}

.view-more-comments {
    color: #007bff;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 0;
}

.view-more-comments:hover {
    text-decoration: underline;
}

/* Trending Sidebar */
.trending-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.trending-sidebar h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #fff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.trending-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trending-item {
    background: rgba(255, 255, 255, 0.95);
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.trending-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.trending-rank {
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1rem;
    margin-bottom: 5px;
}

.trending-text {
    font-size: 0.9rem;
    color: #444;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trending-score {
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
}

/* Loading & No More */
.loading, .no-more {
    text-align: center;
    padding: 20px;
    color: #888;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

/* Drag handle for mobile sheet */
.modal-drag-handle {
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
}

.modal-header h3 {
    font-size: 1.2rem;
}

.close-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.close-btn:active {
    transform: scale(0.95);
}

.modal-comments {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.comment-form {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.comment-form input,
.comment-form textarea {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
}

.comment-form input:focus,
.comment-form textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.comment-form textarea {
    min-height: 60px;
    resize: vertical;
}

.comment-form button {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 14px 24px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    align-self: flex-end;
    font-size: 16px;
    font-weight: 600;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 123, 255, 0.2);
}

.comment-form button:hover {
    background: #0056b3;
}

.comment-form button:active {
    transform: scale(0.98);
}

/* Footer */
.footer {
    text-align: right;
    padding: 30px 20px 20px;
    margin-top: 40px;
}

.footer-link {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    display: inline-block;
    font-style: italic;
}

.footer-link:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    letter-spacing: 1px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100%;
    }

    .container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
    }

    .header {
        padding: 15px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .post-form {
        padding: 15px;
        margin-bottom: 15px;
    }

    .main-content {
        flex-direction: column;
        width: 100%;
    }

    .feed-section {
        width: 100%;
    }

    .complaint-card {
        padding: 15px;
        max-width: 100%;
    }

    .complaint-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .social-share-icons {
        gap: 8px;
    }

    /* MOB-001: Touch targets maintained on mobile */
    .share-icon-btn {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    .share-icon-btn svg {
        width: 20px;
        height: 20px;
    }

    .trending-sidebar {
        width: 100%;
        order: -1;
        margin-bottom: 20px;
    }

    .trending-list {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .trending-list::-webkit-scrollbar {
        display: none;
    }

    .trending-item {
        min-width: 200px;
        flex-shrink: 0;
    }

    /* MOB-001: Reaction buttons - maintain touch targets */
    .reactions-bar {
        gap: 4px;
    }

    .reaction-btn {
        padding: 8px 10px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }

    /* MOB-001: Action buttons - maintain touch targets */
    .action-btn {
        padding: 10px 12px;
        min-width: 44px;
        min-height: 44px;
    }

    /* MOB-004: Modal as bottom sheet on mobile */
    .modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: 20px 20px 0 0;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    /* MOB-004: Drag handle visible on mobile */
    .modal-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
        margin: 12px auto 0;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-comments {
        padding: 16px;
    }

    /* MOB-003: Comment form sticky at bottom with safe area */
    .comment-form {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .footer {
        padding: 20px 15px 15px;
        margin-top: 30px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    }

    .footer-link {
        font-size: 0.65rem;
    }

    /* MOB-001: Tabs touch targets */
    .tabs {
        gap: 8px;
    }

    .tab {
        padding: 12px 16px;
        min-height: 48px;
        flex: 1;
        text-align: center;
    }
}

/* MOB-003: Body adjustment when keyboard is open */
body.keyboard-open .modal-content {
    max-height: 100%;
}

body.keyboard-open .comment-form {
    padding-bottom: 16px;
}

/* MOB-005: Additional overflow prevention */
.complaint-author {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ==========================================================================
   MOB-007: Very small screens (iPhone SE, etc.) - WCAG Compliant
   Touch targets maintained at 44px minimum
   ========================================================================== */
@media (max-width: 374px) {
    /* Reactions bar becomes horizontally scrollable */
    .reactions-bar {
        gap: 2px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-right: 25px;
        position: relative;
    }

    .reactions-bar::-webkit-scrollbar {
        display: none;
    }

    /* WCAG 2.1 AAA Compliant - 44px minimum touch targets */
    .reaction-btn {
        padding: 6px 8px;
        min-width: 44px;
        min-height: 44px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }

    /* Hide external count badge on very small screens */
    .reactions-count {
        display: none;
    }

    .tab {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    /* WCAG 2.1 AAA Compliant - 44px minimum for share buttons */
    .share-icon-btn {
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
    }

    .share-icon-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Scroll fade indicator for reactions bar */
    .complaint-card .reactions-bar::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.95));
        pointer-events: none;
    }
}

/* Reaction count inside buttons */
.reaction-btn .reaction-count {
    font-size: 0.75rem;
    color: #666;
    font-weight: 600;
    min-width: 14px;
    text-align: center;
}

.reaction-btn.active .reaction-count {
    color: #667eea;
}

.reaction-btn:hover .reaction-count {
    color: #667eea;
}

/* Better spacing for reaction buttons with counts */
.reactions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.comment-reactions .reaction-btn .reaction-count {
    font-size: 0.7rem;
}

/* ==========================================================================
   MOB-010: Network Status Indicators
   Offline indicator and toast notifications
   ========================================================================== */

/* Offline indicator bar */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    z-index: 10000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.offline-indicator.visible {
    transform: translateY(0);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 90%;
    width: 320px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-info {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}
