/* assets/css/admin.css - Complete Optimized Version */

/* ===========================
   CSS Variables
   =========================== */
:root {
    --admin-primary: #2c3e50;
    --admin-secondary: #3498db;
    --admin-success: #27ae60;
    --admin-danger: #e74c3c;
    --admin-warning: #f39c12;
    --admin-light: #ecf0f1;
    --admin-dark: #34495e;
    --admin-sidebar-width: 250px;
    --admin-header-height: 60px;
}

/* ===========================
   Global Admin Styles
   =========================== */
.admin-body {
    margin: 0;
    padding: 0;
    background: #f5f7fa;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
}

/* ===========================
   Admin Login Page
   =========================== */
.admin-login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.admin-login-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
    padding: 3rem;
}

.admin-login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.admin-login-header img {
    max-height: 60px;
    margin-bottom: 1rem;
}

.admin-login-header h2 {
    font-size: 1.5rem;
    color: var(--admin-primary);
    margin-bottom: 0.5rem;
}

.admin-login-header p {
    color: #7f8c8d;
}

/* Login Form */
.admin-login-form .form-group {
    margin-bottom: 1.5rem;
}

.admin-login-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--admin-primary);
    font-weight: 500;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--admin-secondary);
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0.5rem;
}

.admin-submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.admin-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* ===========================
   Admin Dashboard Layout
   =========================== */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--admin-header-height);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.admin-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 2rem;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-logo img {
    height: 35px;
}

.admin-logo span {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--admin-primary);
}

.admin-user-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.admin-user-menu #adminEmail {
    color: #7f8c8d;
}

.logout-btn {
    background: var(--admin-danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.logout-btn:hover {
    background: #c0392b;
}

/* Admin Layout Container */
.admin-layout {
    display: flex;
    margin-top: var(--admin-header-height);
    min-height: calc(100vh - var(--admin-header-height));
}

/* Admin Sidebar */
.admin-sidebar {
    width: var(--admin-sidebar-width);
    background: var(--admin-primary);
    flex-shrink: 0;
}

.admin-nav {
    padding: 1rem 0;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.admin-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.admin-nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.admin-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--admin-secondary);
}

.admin-nav-item i {
    width: 20px;
    text-align: center;
}

/* Admin Main Content */
.admin-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: #f5f7fa;
}

/* Admin Sections */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-section-header {
    margin-bottom: 2rem;
}

.admin-section-header h1 {
    font-size: 2rem;
    color: var(--admin-primary);
    margin-bottom: 0.5rem;
}

.admin-section-header p {
    color: #7f8c8d;
}

/* ===========================
   Dashboard Components
   =========================== */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.stat-content h3 {
    font-size: 2rem;
    color: var(--admin-primary);
    margin: 0;
}

.stat-content p {
    color: #7f8c8d;
    margin: 0;
}

/* Recent Posts */
.recent-posts {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.recent-posts h2 {
    margin-bottom: 1.5rem;
    color: var(--admin-primary);
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.post-item {
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.post-item:hover {
    background: #f5f7fa;
    border-color: var(--admin-secondary);
}

.post-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.post-item h3 {
    font-size: 1.1rem;
    color: var(--admin-primary);
    margin: 0;
}

.post-item-date {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.post-item-meta {
    display: flex;
    gap: 1rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

/* ===========================
   Form Styles
   =========================== */
.post-form {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--admin-primary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--admin-secondary);
}

/* Image Upload */
.image-upload-area {
    position: relative;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem;
    border: 2px dashed #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-label:hover {
    border-color: var(--admin-secondary);
    background: #f5f7fa;
}

.image-upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    margin-top: 1rem;
}

/* Editor */
.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: #f5f7fa;
    border: 1px solid #e0e0e0;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.toolbar-btn:hover {
    background: var(--admin-secondary);
    color: white;
    border-color: var(--admin-secondary);
}

.quill-editor {
    background: white;
    min-height: 400px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background: white;
    color: var(--admin-primary);
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #f5f7fa;
}

/* ===========================
   Posts Table
   =========================== */
.posts-table-container {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.posts-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.posts-table th {
    text-align: left;
    padding: 1rem;
    color: var(--admin-primary);
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
}

.posts-table td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.posts-table tr:hover {
    background: #f5f7fa;
}

/* Column widths */
.posts-table th:first-child,
.posts-table td:first-child {
    width: 35%;
}

.posts-table th:last-child,
.posts-table td:last-child {
    width: 200px;
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.edit-btn,
.delete-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.edit-btn {
    background: var(--admin-success);
    color: white;
}

.edit-btn:hover {
    background: #229954;
}

.delete-btn {
    background: var(--admin-danger);
    color: white;
}

.delete-btn:hover {
    background: #c0392b;
}

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

.category-badge.fundraising {
    background: #e3f2fd;
    color: #1976d2;
}

.category-badge.strategy {
    background: #f3e5f5;
    color: #7b1fa2;
}

.category-badge.operations {
    background: #e8f5e9;
    color: #388e3c;
}

.category-badge.technology {
    background: #fff3e0;
    color: #f57c00;
}

/* ===========================
   Modal
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.modal-content {
    background: white;
    max-width: 600px;
    margin: 5% auto;
    border-radius: 10px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

/* ===========================
   Messages
   =========================== */
.success-message,
.error-message {
    padding: 1rem;
    border-radius: 5px;
    margin-top: 1rem;
    display: none;
}

.success-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.edit-note {
    background: #e3f2fd;
    color: #1976d2;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        order: -1;
    }

    .admin-nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
        -webkit-overflow-scrolling: touch;
    }

    .admin-nav-item {
        white-space: nowrap;
        padding: 1rem;
    }

    .admin-main {
        padding: 1rem;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .posts-table {
        font-size: 0.85rem;
    }

    .posts-table th,
    .posts-table td {
        padding: 0.5rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* ADD TO END OF assets/css/admin.css */

/* CRITICAL LAYOUT FIXES */
body.admin-body {
    margin: 0 !important;
    padding: 0 !important;
    background: #f5f7fa !important;
    overflow-x: hidden !important;
}

.admin-layout {
    display: flex !important;
    margin-top: 60px !important;
    min-height: calc(100vh - 60px) !important;
}

.admin-sidebar {
    position: relative !important;
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
    background: #2c3e50 !important;
    height: calc(100vh - 60px) !important;
    overflow-y: auto !important;
    flex-shrink: 0 !important;
}

.admin-main {
    flex: 1 !important;
    padding: 30px !important;
    margin-left: 0 !important;
    overflow-x: auto !important;
    background: #f5f7fa !important;
}

/* TABLE FIXES */
.posts-table-container {
    overflow-x: auto !important;
    width: 100% !important;
}

.posts-table {
    width: 100% !important;
    min-width: 1000px !important;
}

.posts-table th:last-child,
.posts-table td:last-child {
    width: 200px !important;
    min-width: 200px !important;
    text-align: center !important;
}

/* BUTTON FIXES */
.action-buttons {
    display: flex !important;
    gap: 8px !important;
    justify-content: center !important;
    align-items: center !important;
}

.edit-btn,
.delete-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 8px 16px !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: white !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
}

.edit-btn {
    background: #27ae60 !important;
}

.edit-btn:hover {
    background: #229954 !important;
}

.delete-btn {
    background: #e74c3c !important;
}

.delete-btn:hover {
    background: #c0392b !important;
}