/* ============================================
   ADMIN DASHBOARD - GLOBAL STYLES
   ============================================ */

:root {
    --primary: #a30303;
    --primary-dark: #7a0202;
    --secondary: #0f172a;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #eef2f7;
    --bg-secondary: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   AUTH LOADING SCREEN
   ============================================ */

.auth-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

.loading-content h2 {
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 600;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   AUTHENTICATION STYLES
   ============================================ */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.auth-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 28px;
    margin-bottom: 5px;
    color: var(--primary);
}

.auth-header h1 span {
    color: var(--primary-dark);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(163, 3, 3, 0.1);
}

.form-group small {
    font-size: 12px;
    color: var(--text-secondary);
}

.auth-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 10px;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================
   ADMIN LAYOUT
   ============================================ */

.admin-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* SIDEBAR */
.admin-sidebar {
    background: var(--secondary);
    color: white;
    padding: 20px;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 90;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.sidebar-header .logo {
    font-size: 20px;
    font-weight: 700;
}

.sidebar-header .logo span {
    color: var(--primary);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.mobile-toggle {
    display: none;
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    margin-right: 15px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    text-align: left;
    width: 100%;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item .icon {
    font-size: 18px;
}

.nav-item .label {
    font-size: 14px;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

/* MAIN CONTENT */
.admin-main {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.admin-header {
    background: var(--bg-secondary);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.admin-title h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.admin-title p {
    color: var(--text-secondary);
    font-size: 14px;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.admin-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

/* ============================================
   CONTENT SECTIONS
   ============================================ */

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   CARD COMPONENT
   ============================================ */

.card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ============================================
   DASHBOARD STATS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 32px;
}

.stat-content h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ============================================
   POSTS LIST
   ============================================ */

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    transition: all 0.2s;
}

.post-item:hover {
    background: #f0f4f8;
}

.post-item-info h4 {
    font-size: 14px;
    margin-bottom: 3px;
}

.post-item-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.post-meta {
    font-size: 12px;
    color: var(--text-secondary);
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-action-btn {
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    text-align: left;
}

.quick-action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================
   FORM STYLES
   ============================================ */

.post-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(163, 3, 3, 0.1);
}

textarea {
    font-family: inherit;
    resize: vertical;
    min-height: 150px;
}

/* PASSWORD INPUT CONTAINER */
.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-container input {
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.password-toggle:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* IMAGE UPLOAD */
.image-upload {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-primary);
}

.image-upload:hover {
    border-color: var(--primary);
    background: rgba(163, 3, 3, 0.05);
}

.image-upload input {
    display: none;
}

.upload-hint p {
    font-weight: 600;
    margin-bottom: 5px;
}

.upload-hint small {
    color: var(--text-secondary);
}

.image-preview {
    margin-top: 15px;
    display: none;
}

.image-preview.active {
    display: block;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.image-remove-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* FORM ACTIONS */
.form-actions,
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 20px;
}

.form-actions button,
.modal-actions button {
    flex: 1;
    min-width: 150px;
}

/* PREVIEW PANE */
.preview-pane {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    width: 100%;
    text-align: left;
}

.preview-content h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

.preview-content .preview-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 12px;
    color: var(--text-secondary);
}

.preview-content p {
    line-height: 1.8;
    color: var(--text-secondary);
}

/* ============================================
   POSTS MANAGEMENT
   ============================================ */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-controls {
    display: flex;
    gap: 10px;
}

.search-input,
.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.search-input {
    flex: 1;
    min-width: 250px;
}

.posts-management-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-row {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.post-row-info {
    flex: 1;
    min-width: 250px;
}

.post-row-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.post-row-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 15px;
}

.post-row-actions {
    display: flex;
    gap: 8px;
}

.post-row-actions .btn {
    padding: 8px 12px;
    font-size: 12px;
}

/* ============================================
   ADMINS MANAGEMENT
   ============================================ */

.admins-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-item-info {
    flex: 1;
    min-width: 200px;
}

.admin-item-name {
    font-weight: 600;
    margin-bottom: 3px;
}

.admin-item-email {
    font-size: 14px;
    color: var(--text-secondary);
}

.admin-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-role {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--primary);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary);
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 300px;
    animation: slideIn 0.3s ease-in;
}

.notification.success {
    border-color: var(--success);
}

.notification.error {
    border-color: var(--danger);
}

.notification.warning {
    border-color: var(--warning);
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   INFO GRID
   ============================================ */

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.info-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.info-item p {
    font-size: 16px;
    font-weight: 600;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .admin-container {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed;
        left: -250px;
        transition: left 0.3s;
        z-index: 95;
    }

    .admin-sidebar.open {
        left: 0;
    }

    .admin-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-header .logo {
        display: none;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-controls {
        width: 100%;
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .post-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .post-row-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .notification-container {
        left: 20px;
        right: 20px;
    }

    .notification {
        min-width: unset;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .admin-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .mobile-toggle {
        display: block !important;
        order: -1;
    }

    .admin-content {
        padding: 15px;
    }

    .card {
        padding: 15px;
    }

    .auth-box {
        padding: 25px;
    }

    .form-actions button,
    .modal-actions button {
        min-width: 100%;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
