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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f6f8;
    color: #2c3e50;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    background-color: #1e293b;
    color: #ffffff;
    padding: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 a {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.5rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

nav a {
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
}

nav a:hover {
    color: #ffffff;
}

.user-greeting {
    color: #94a3b8;
    margin-right: 5px;
}

.btn-nav {
    padding: 6px 14px;
    border-radius: 6px;
    background-color: #334155;
    font-size: 0.9rem;
}

.admin-btn {
    background-color: #0284c7;
    color: #ffffff !important;
}

.logout-btn {
    background-color: #ef4444;
    color: #ffffff !important;
}

/* Main Layout */
.main-container {
    max-width: 1000px;
    width: 100%;
    margin: 30px auto;
    padding: 25px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
}

/* Footer */
footer {
    background-color: #0f172a;
    color: #94a3b8;
    padding: 20px 0;
    font-size: 0.85rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.footer-container a {
    color: #38bdf8;
    text-decoration: none;
}

.grant-info {
    margin-bottom: 8px;
    color: #cbd5e1;
}

/* Grid & Cards */
.subtitle {
    color: #64748b;
    margin-bottom: 25px;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.article-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
}

.card-img-link {
    display: block;
    height: 180px;
    background-color: #e2e8f0;
    overflow: hidden;
}

.card-img-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-img {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-style: italic;
}

.card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-body h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.card-body h3 a {
    color: #1e293b;
    text-decoration: none;
}

.card-body h3 a:hover {
    color: #0284c7;
}

.card-excerpt {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 15px;
    flex: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #64748b;
    border-top: 1px solid #f1f5f9;
    padding-top: 10px;
}

/* Single Article View */
.single-article {
    margin-bottom: 30px;
}

.article-meta {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 15px;
}

/* STL 3D Viewer Styles */
.stl-viewer-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

.stl-viewer-section h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: #0f172a;
}

.stl-hint {
    font-size: 0.82rem;
    color: #64748b;
    margin-bottom: 12px;
}

#stl-canvas-container {
    width: 100%;
    height: 400px;
    background-color: #1e293b;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#stl-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.8);
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid #334155;
}

.stl-download-box {
    margin-top: 12px;
    text-align: right;
}

.btn-stl-download {
    display: inline-block;
    padding: 8px 16px;
    background-color: #0284c7;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
}

.btn-stl-download:hover {
    background-color: #0369a1;
}

.stl-status {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.article-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: opacity 0.2s;
}

.gallery-item img:hover {
    opacity: 0.9;
}

.article-content {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 25px;
}

.like-section {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f8fafc;
    padding: 12px 20px;
    border-radius: 6px;
}

.like-btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #10b981;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
}

.like-btn.liked {
    background-color: #ef4444;
}

/* Form Styles */
.form-card {
    max-width: 450px;
    margin: 20px auto;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #f8fafc;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}

button, .btn-primary {
    display: inline-block;
    padding: 10px 18px;
    background-color: #0284c7;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

button:hover, .btn-primary:hover {
    background-color: #0369a1;
}

.btn-cancel {
    display: inline-block;
    margin-left: 10px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.9rem;
}

.alert {
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Comments Section */
.divider {
    border: 0;
    height: 1px;
    background: #e2e8f0;
    margin: 30px 0;
}

.comment-form {
    margin: 15px 0 25px 0;
}

.comment-form textarea {
    height: 80px;
    margin-bottom: 10px;
}

.comment-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.comment-date {
    color: #94a3b8;
}

.admin-comment-controls {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-date-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.small-input {
    width: auto !important;
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
}

.btn-small {
    padding: 4px 10px !important;
    font-size: 0.8rem !important;
    background-color: #475569 !important;
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #e2e8f0;
    padding: 6px 10px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border: 1px solid #cbd5e1;
    border-bottom: none;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background-color: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background-color: #f1f5f9;
}

.toolbar-select {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    font-size: 0.85rem;
    background: #ffffff;
}

.editor-toolbar + textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 8px 16px;
    background-color: #f1f5f9;
    color: #475569;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
}

.tab-btn.active {
    background-color: #0284c7;
    color: #ffffff;
}

/* Admin Comments List */
.admin-comments-container {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.admin-comments-list {
    list-style: none;
    margin-top: 15px;
}

.admin-comment-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.comm-meta {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 8px;
}

.comm-text {
    font-size: 0.95rem;
    margin-bottom: 12px;
    background: #f8fafc;
    padding: 8px 12px;
    border-left: 3px solid #0284c7;
    border-radius: 4px;
}

.comm-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Admin Panel Layout */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

.admin-form-container, .admin-list-container {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.thumb-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.thumb-box {
    position: relative;
    display: inline-block;
}

.thumb-box img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.thumb-box .delete-img-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 18px;
    font-size: 11px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.admin-list {
    list-style: none;
    margin-top: 15px;
}

.admin-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-item-date {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
}

.action-btn {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}

.edit-btn {
    background: #e0f2fe;
    color: #0369a1;
}

.delete-btn {
    background: #fee2e2;
    color: #b91c1c;
}
