/* Admin Panel Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5530;
    --secondary-color: #34a853;
    --accent-color: #f4b942;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --success-color: #27ae60;
    --info-color: #3498db;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #95a5a6;
    --white: #ffffff;
    --light-bg: #f8f9fa;
    --dark-bg: #2c3e50;
    --border-color: #dee2e6;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 5px 20px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 10px 30px rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --sidebar-width: 280px;
    --topbar-height: 70px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark-bg);
    color: var(--white);
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.3em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 i {
    color: var(--accent-color);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.menu-link:hover,
.menu-link.active {
    background: rgba(52, 168, 83, 0.2);
    color: var(--white);
    border-right: 3px solid var(--secondary-color);
}

.menu-link i {
    font-size: 1.1em;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.back-to-blog {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 10px 0;
    transition: var(--transition);
    font-weight: 500;
}

.back-to-blog:hover {
    color: var(--accent-color);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.topbar {
    background: var(--white);
    height: var(--topbar-height);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 999;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 10px;
    color: var(--text-dark);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.mobile-toggle:hover {
    background: var(--light-bg);
}

.page-title {
    font-size: 1.8em;
    font-weight: 600;
    color: var(--primary-color);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
    font-weight: 500;
}

.user-menu i {
    font-size: 1.8em;
    color: var(--primary-color);
}

/* Content Wrapper */
.content-wrapper {
    padding: 30px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-secondary {
    background: var(--text-light);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-warning:hover {
    background: #d68910;
}

.btn-info {
    background: var(--info-color);
    color: var(--white);
}

.btn-info:hover {
    background: #2980b9;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    border-left: 4px solid var(--secondary-color);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.stat-card:nth-child(2) {
    border-left-color: var(--info-color);
}

.stat-card:nth-child(3) {
    border-left-color: var(--danger-color);
}

.stat-card:nth-child(4) {
    border-left-color: var(--warning-color);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary-color);
    color: var(--white);
    font-size: 1.5em;
}

.stat-card:nth-child(2) .stat-icon {
    background: var(--info-color);
}

.stat-card:nth-child(3) .stat-icon {
    background: var(--danger-color);
}

.stat-card:nth-child(4) .stat-icon {
    background: var(--warning-color);
}

.stat-info h3 {
    font-size: 2em;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-light);
    font-weight: 500;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.recent-posts,
.popular-posts {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.recent-posts h3,
.popular-posts h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.2em;
    font-weight: 600;
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.post-item {
    padding: 15px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.post-item:hover {
    border-color: var(--secondary-color);
    background: rgba(52, 168, 83, 0.05);
}

.post-item h4 {
    color: var(--text-dark);
    font-size: 0.95em;
    margin-bottom: 8px;
    font-weight: 600;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-light);
    font-size: 0.85em;
}

.post-stats {
    display: flex;
    gap: 15px;
}

.post-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Posts Management */
.section-header {
    margin-bottom: 25px;
}

.search-filter {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 300px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--white);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.1);
}

.filter-select {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--white);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.posts-table-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    overflow: hidden;
}

.posts-table {
    width: 100%;
    border-collapse: collapse;
}

.posts-table th,
.posts-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.posts-table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.posts-table tr:hover {
    background: rgba(52, 168, 83, 0.05);
}

.posts-table .post-title {
    font-weight: 600;
    color: var(--text-dark);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--secondary-color);
    color: var(--white);
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 500;
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* Form Styles */
.post-form {
    background: var(--white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 300px;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

.form-hint {
    color: var(--text-light);
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
}

/* API Section */
.api-info,
.api-endpoints,
.api-test {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 25px;
}

.api-info h3,
.api-endpoints h3,
.api-test h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.2em;
}

.api-details {
    display: grid;
    gap: 15px;
}

.api-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
}

.api-item label {
    font-weight: 600;
    color: var(--text-dark);
    min-width: 100px;
}

.api-item code {
    flex: 1;
    background: var(--dark-bg);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.copy-btn {
    background: var(--info-color);
    color: var(--white);
    border: none;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: #2980b9;
}

.endpoints-list {
    display: grid;
    gap: 10px;
}

.endpoint-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    border-left: 4px solid transparent;
}

.endpoint-method {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    color: var(--white);
    min-width: 60px;
    text-align: center;
}

.endpoint-method.get {
    background: var(--success-color);
}

.endpoint-method.post {
    background: var(--info-color);
}

.endpoint-method.put {
    background: var(--warning-color);
}

.endpoint-method.delete {
    background: var(--danger-color);
}

.endpoint-path {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.endpoint-desc {
    color: var(--text-light);
    font-size: 0.9em;
}

.test-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.test-select,
.test-input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.test-input {
    flex: 1;
    min-width: 200px;
}

.test-body {
    margin-bottom: 20px;
}

.test-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.test-body textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.test-response label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.test-response pre {
    background: var(--dark-bg);
    color: var(--white);
    padding: 15px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
}

/* Statistics */
.stats-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.chart-container {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.chart-container h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.1em;
}

.detailed-stats {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.detailed-stats h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.2em;
}

.stats-list {
    display: grid;
    gap: 15px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--secondary-color);
}

.stats-label {
    font-weight: 600;
    color: var(--text-dark);
}

.stats-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1em;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--white);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-heavy);
    position: relative;
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light-bg);
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.3em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-light);
    padding: 5px;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-dark);
    background: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--light-bg);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }
    
    .stats-charts {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .search-filter {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .topbar {
        padding: 0 20px;
    }
    
    .page-title {
        font-size: 1.5em;
    }
    
    .topbar-actions {
        gap: 10px;
    }
    
    .content-wrapper {
        padding: 20px 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-info h3 {
        font-size: 1.5em;
    }
    
    .posts-table-container {
        overflow-x: auto;
    }
    
    .posts-table {
        min-width: 800px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .test-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .test-input {
        min-width: auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 0 15px;
    }
    
    .page-title {
        font-size: 1.3em;
    }
    
    .user-menu span {
        display: none;
    }
    
    .content-wrapper {
        padding: 15px 10px;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3em;
    }
    
    .table-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .btn-sm {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .api-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .api-item label {
        min-width: auto;
    }
    
    .endpoint-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .endpoint-method {
        min-width: auto;
        width: fit-content;
    }
}

/* Loading Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: var(--white);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

.notification.error {
    background: var(--danger-color);
}

.notification.warning {
    background: var(--warning-color);
}

.notification.info {
    background: var(--info-color);
}

.notification-close {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px;
    border-radius: 3px;
    opacity: 0.8;
    transition: var(--transition);
    margin-left: auto;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Fade in animation for content */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section.active {
    animation: fadeIn 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

/* Focus styles for accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .sidebar,
    .topbar,
    .form-actions,
    .table-actions,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-wrapper {
        padding: 0;
    }
    
    .posts-table {
        font-size: 12px;
    }
    
    .stat-card {
        break-inside: avoid;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 5px 20px rgba(0, 0, 0, 0.4);
        --shadow-heavy: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}