/* ============================================
   MAIN PAGE STYLES
   File: index.css
   ============================================ */

/* ---------- GLOBAL RESET ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- HEADER ---------- */
header {
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

h1 {
    font-size: 24px;
    color: #1a1a1a;
}

header div {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

header span {
    font-size: 14px;
    color: #555;
}

p {
    overflow-wrap: break-word;
}

#logout-btn {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#logout-btn:hover {
    background: #c82333;
}

/* ---------- CREATE POST BUTTON ---------- */
#create-post-btn {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

#create-post-btn:hover {
    background: #218838;
}

/* ---------- POST CARDS ---------- */
.post-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.post-card h3 {
    margin-bottom: 8px;
    color: #1a1a1a;
}

.post-card p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 12px;
}

/* ---------- POST META ---------- */
.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 13px;
    color: #888;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- POST STATUS BADGES ---------- */
.status-approved {
    background: #d4edda;
    color: #155724;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ---------- POST ACTION BUTTONS ---------- */
.post-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.post-actions button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-approve {
    background: #28a745;
    color: white;
}

.btn-approve:hover {
    background: #218838;
}

.btn-revoke {
    background: #ffc107;
    color: #333;
}

.btn-revoke:hover {
    background: #e0a800;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.post-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- LOADING AND ERROR MESSAGES ---------- */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 16px;
}

.error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
    font-size: 16px;
}

/* ---------- MODAL WINDOW ---------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    width: 460px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #1a1a1a;
}

.modal-content label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-content input:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: #4A90D9;
}

.modal-content textarea {
    height: 120px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.modal-actions button {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-save {
    background: #4A90D9;
    color: white;
}

.btn-save:hover {
    background: #357ABD;
}

.modal-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- RESPONSIVENESS ---------- */
@media (max-width: 640px) {
    body {
        padding: 12px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    header div {
        justify-content: center;
    }

    .modal-content {
        padding: 24px;
    }
}

/* ---------- GUEST / AUTHORIZED MODE ---------- */
.user-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

#guest-controls {
    display: block;
}

#user-controls {
    display: none;
    align-items: center;
    gap: 12px;
}

#user-login-display {
    font-weight: 500;
    color: #333;
}

/* ---------- COMMON BUTTONS ---------- */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-primary {
    background: #4A90D9;
    color: white;
}
.btn-primary:hover {
    background: #357ABD;
}

.btn-success {
    background: #28a745;
    color: white;
}
.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}
.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}
.btn-warning:hover {
    background: #e0a800;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}
.btn-secondary:hover {
    background: #5a6268;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- STATUS BADGES ---------- */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

#user-access-display {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 12px;
    background: #e9ecef;
    color: #495057;
}

/* ---------- ROLE BADGES ---------- */
.role-guest {
    background: #e9ecef;
    color: #495057;
}

.role-moderator {
    background: #cce5ff;
    color: #004085;
}

.role-admin {
    background: #f8d7da;
    color: #721c24;
}

/* ---------- CONTROL PANEL ---------- */
.controls-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Last update indicator */
.last-update {
    font-size: 13px;
    color: #888;
    margin-left: auto;
}

/* Refresh button */
#refresh-posts-btn {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

#refresh-posts-btn:hover:not(:disabled) {
    background: #5a6268;
}

#refresh-posts-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- RESPONSIVENESS FOR CONTROL PANEL ---------- */
@media (max-width: 640px) {
    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .last-update {
        margin-left: 0;
        text-align: center;
        font-size: 12px;
    }

    #refresh-posts-btn,
    #create-post-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ---------- POST LINK STYLES ---------- */
.post-link {
    display: inline-block;
    margin: 8px 0;
    padding: 6px 12px;
    background: #e3f2fd;
    border-radius: 4px;
    color: #0d47a1;
    text-decoration: none;
    font-size: 14px;
    word-break: break-all;
}

.post-link:hover {
    background: #bbdefb;
}

/* ---------- FILE ATTACHMENTS STYLES ---------- */
.post-files {
    margin: 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px;
    max-width: 150px;
    text-align: center;
    transition: transform 0.2s;
}

.file-item:hover {
    transform: scale(1.02);
}

.file-preview {
    max-width: 100%;
    max-height: 120px;
    border-radius: 4px;
    object-fit: cover;
}

.file-name {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    word-break: break-all;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    color: #4A90D9;
    font-size: 13px;
    transition: background 0.2s;
}

.file-link:hover {
    background: #e9ecef;
}