/* ===========================
   Variables & Reset
   =========================== */
:root {
    --primary-color: #0066ff;
    --primary-hover: #0052cc;
    --secondary-color: #6b7280;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===========================
   Header
   =========================== */
.admin-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-logo {
    height: 40px;
    width: auto;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-back {
    padding: 0.625rem 1.25rem;
    background: var(--bg-light);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.btn-back:hover {
    background: var(--border-color);
}

/* User Info & Logout */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.btn-logout {
    padding: 0.625rem 1.25rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
}

.btn-logout:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ===========================
   Main Container
   =========================== */
.admin-main {
    padding: 2rem;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ===========================
   Actions Bar
   =========================== */
.actions-bar {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-filter {
    display: flex;
    gap: 1rem;
    flex: 1;
    max-width: 600px;
}

.search-input,
.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition);
    font-family: inherit;
}

.search-input {
    flex: 1;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.filter-select {
    min-width: 180px;
}

/* ===========================
   Buttons
   =========================== */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

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

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

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

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

/* ===========================
   Articles Section
   =========================== */
.articles-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.articles-list {
    display: grid;
    gap: 1rem;
}

.article-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    align-items: start;
    transition: var(--transition);
}

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

.article-image {
    width: 120px;
    height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--bg-light);
}

.article-info {
    flex: 1;
}

.article-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.article-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, #00d4ff, #0066ff);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.article-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.article-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.article-excerpt {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.article-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    padding: 0.125rem 0.5rem;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 0.75rem;
}

.article-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-icon:hover {
    background: var(--bg-light);
}

.btn-icon.edit:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-icon.delete:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* ===========================
   Modal
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-width: 500px;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* ===========================
   Form
   =========================== */
#articleForm {
    padding: 1.5rem;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

input[type="text"],
input[type="url"],
input[type="date"],
select,
textarea {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

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

.warning-text {
    color: var(--danger-color);
    font-weight: 500;
    margin-top: 0.5rem;
}

/* ===========================
   Loading & Empty States
   =========================== */
.loading,
.no-articles {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* ===========================
   Toast Notification
   =========================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    animation: slideInRight 0.3s ease;
    z-index: 2000;
}

.toast.show {
    display: block;
}

.toast.success {
    background: var(--success-color);
}

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

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

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    .admin-header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .header-right {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
    }

    .admin-nav {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .admin-main {
        padding: 1rem;
    }

    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-filter {
        flex-direction: column;
        max-width: none;
    }

    .article-card {
        grid-template-columns: 1fr;
    }

    .article-image {
        width: 100%;
        height: 200px;
    }

    .article-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }
}
