/* Catppuccin Mocha Color Palette */
:root {
    --ctp-rosewater: #f5e0dc;
    --ctp-flamingo: #f2cdcd;
    --ctp-pink: #f5c2e7;
    --ctp-mauve: #cba6f7;
    --ctp-red: #f38ba8;
    --ctp-maroon: #eba0ac;
    --ctp-peach: #fab387;
    --ctp-yellow: #f9e2af;
    --ctp-green: #a6e3a1;
    --ctp-teal: #94e2d5;
    --ctp-sky: #89dceb;
    --ctp-sapphire: #74c7ec;
    --ctp-blue: #89b4fa;
    --ctp-lavender: #b4befe;
    --ctp-text: #cdd6f4;
    --ctp-subtext1: #bac2de;
    --ctp-subtext0: #a6adc8;
    --ctp-overlay2: #9399b2;
    --ctp-overlay1: #7f849c;
    --ctp-overlay0: #6c7086;
    --ctp-surface2: #585b70;
    --ctp-surface1: #45475a;
    --ctp-surface0: #313244;
    --ctp-base: #1e1e2e;
    --ctp-mantle: #181825;
    --ctp-crust: #11111b;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--ctp-base);
    color: var(--ctp-text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--ctp-mantle);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--ctp-surface0);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    color: var(--ctp-lavender);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--ctp-subtext1);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.nav-link:hover {
    background-color: var(--ctp-surface0);
    color: var(--ctp-text);
}

.nav-link.active {
    background-color: var(--ctp-surface0);
    color: var(--ctp-lavender);
}

.nav-link svg {
    flex-shrink: 0;
}

.nav-form {
    display: contents;
}

.logout-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
    font-family: inherit;
}

.divider {
    border: none;
    border-top: 1px solid var(--ctp-surface0);
    margin: 1.5rem 0;
}

.sidebar-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ctp-overlay0);
    margin-bottom: 0.75rem;
    display: block;
}

.sidebar-articles {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-article {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--ctp-subtext0);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-article:hover {
    background-color: var(--ctp-surface0);
    color: var(--ctp-text);
}

.sidebar-article.active {
    background-color: var(--ctp-surface0);
    color: var(--ctp-lavender);
}

/* Main Content */
.content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem 3rem;
    max-width: 1200px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Notice/Alert */
.notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.notice.danger {
    background-color: rgba(243, 139, 168, 0.1);
    border: 1px solid var(--ctp-red);
    color: var(--ctp-red);
}

.notice.info {
    background-color: rgba(137, 180, 250, 0.1);
    border: 1px solid var(--ctp-blue);
    color: var(--ctp-blue);
}

/* Home Page */
.home-header {
    margin-bottom: 2rem;
}

.home-header h1 {
    font-size: 2.5rem;
    color: var(--ctp-text);
    margin-bottom: 0.5rem;
}

.home-description {
    font-size: 1.125rem;
    color: var(--ctp-subtext0);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--ctp-subtext0);
}

.empty-state svg {
    color: var(--ctp-overlay0);
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    color: var(--ctp-text);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* Article Cards Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.article-card {
    background-color: var(--ctp-surface0);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.article-card-banner {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: var(--ctp-surface1);
}

.article-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.article-card:hover .article-card-banner img {
    transform: scale(1.05);
}

.article-card-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-card-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.article-card-title a {
    color: var(--ctp-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-card-title a:hover {
    color: var(--ctp-lavender);
}

.article-card-excerpt {
    color: var(--ctp-subtext0);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex: 1;
    line-height: 1.5;
}

.article-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--ctp-overlay1);
}

.article-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.article-card-meta svg {
    flex-shrink: 0;
}

/* Article Full View */
.article-full {
    max-width: 800px;
}

.article-banner {
    margin: -2rem -3rem 2rem -3rem;
    aspect-ratio: 21 / 9;
    overflow: hidden;
}

.article-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--ctp-surface0);
}

.article-header h1 {
    font-size: 2.5rem;
    color: var(--ctp-text);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    color: var(--ctp-subtext0);
    font-size: 0.9rem;
}

.article-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Article Content Styling */
.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    color: var(--ctp-text);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.article-content h1 {
    font-size: 2rem;
}

.article-content h2 {
    font-size: 1.5rem;
}

.article-content h3 {
    font-size: 1.25rem;
}

.article-content p {
    margin-bottom: 1.25rem;
    color: var(--ctp-subtext1);
}

.article-content a {
    color: var(--ctp-lavender);
    text-decoration: underline;
    text-decoration-color: rgba(180, 190, 254, 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.2s ease;
}

.article-content a:hover {
    text-decoration-color: var(--ctp-lavender);
}

.article-content strong {
    color: var(--ctp-text);
    font-weight: 600;
}

.article-content em {
    color: var(--ctp-subtext1);
}

.article-content code {
    background-color: var(--ctp-surface0);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    color: var(--ctp-peach);
}

.article-content pre {
    background-color: var(--ctp-mantle);
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--ctp-surface0);
}

.article-content pre code {
    background: none;
    padding: 0;
    color: var(--ctp-text);
    font-size: 0.9rem;
    line-height: 1.6;
}

.article-content blockquote {
    border-left: 4px solid var(--ctp-lavender);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--ctp-subtext0);
    font-style: italic;
}

.article-content hr {
    border: none;
    border-top: 1px solid var(--ctp-surface1);
    margin: 2rem 0;
}

.article-content img,
.article-content .content-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

.article-content figure {
    margin: 1.5rem 0;
}

/* Admin Actions */
.admin-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ctp-surface0);
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--ctp-lavender);
    color: var(--ctp-crust);
}

.btn-primary:hover {
    background-color: var(--ctp-mauve);
}

.btn-secondary {
    background-color: var(--ctp-surface1);
    color: var(--ctp-text);
}

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

.btn-danger {
    background-color: var(--ctp-red);
    color: var(--ctp-crust);
}

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

/* Auth Page */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background-color: var(--ctp-surface0);
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--ctp-text);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ctp-subtext1);
}

.form-group input,
.form-group textarea {
    background-color: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface1);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    color: var(--ctp-text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--ctp-lavender);
    box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--ctp-overlay0);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.help-text {
    font-size: 0.8rem;
    color: var(--ctp-overlay1);
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button input {
    flex: 1;
}

/* Admin Page */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-header h1 {
    font-size: 2rem;
    color: var(--ctp-text);
}

.admin-table-container {
    background-color: var(--ctp-surface0);
    border-radius: 12px;
    overflow: hidden;
}

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

.admin-table th,
.admin-table td {
    padding: 1rem 1.25rem;
    text-align: left;
}

.admin-table th {
    background-color: var(--ctp-surface1);
    color: var(--ctp-subtext1);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    border-top: 1px solid var(--ctp-surface1);
}

.admin-table tr:hover td {
    background-color: rgba(180, 190, 254, 0.05);
}

.table-link {
    color: var(--ctp-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.table-link:hover {
    color: var(--ctp-lavender);
}

.date-cell {
    color: var(--ctp-subtext0);
    white-space: nowrap;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Editor */
.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 8rem);
}

.editor-header {
    margin-bottom: 1.5rem;
}

.editor-header h1 {
    font-size: 2rem;
    color: var(--ctp-text);
}

.editor-form {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.editor-main .form-group:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    background-color: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--ctp-subtext1);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
}

.toolbar-btn:hover {
    background-color: var(--ctp-surface0);
    color: var(--ctp-text);
}

.toolbar-btn.active {
    background-color: var(--ctp-surface1);
    color: var(--ctp-lavender);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background-color: var(--ctp-surface1);
    margin: 6px 0.5rem;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

.editor-wrapper textarea {
    flex: 1;
    resize: none;
    border-radius: 0 0 8px 8px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 1rem;
}

.editor-preview {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--ctp-surface0);
    border: 1px solid var(--ctp-surface1);
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    overflow-y: auto;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
}

.editor-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--ctp-overlay1);
}

.char-count {
    font-size: 0.8rem;
    color: var(--ctp-overlay0);
}

.editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.editor-panel {
    background-color: var(--ctp-surface0);
    border-radius: 12px;
    padding: 1.25rem;
}

.editor-panel h3 {
    font-size: 0.9rem;
    color: var(--ctp-subtext1);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.banner-preview {
    aspect-ratio: 16 / 9;
    background-color: var(--ctp-surface1);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-placeholder {
    color: var(--ctp-overlay0);
    font-size: 0.85rem;
}

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

/* Upload Overlay */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(17, 17, 27, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.upload-modal {
    background-color: var(--ctp-surface0);
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
}

.upload-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--ctp-surface1);
    border-top-color: var(--ctp-lavender);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
.footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    color: var(--ctp-overlay0);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .editor-form {
        grid-template-columns: 1fr;
    }
    
    .editor-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .editor-panel {
        flex: 1;
        min-width: 250px;
    }
    
    .editor-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .editor-actions .btn {
        flex: 1;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--ctp-surface0);
    }
    
    .sidebar-articles {
        display: none;
    }
    
    .content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .article-banner {
        margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    }
    
    .article-header h1 {
        font-size: 1.75rem;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--ctp-mantle);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--ctp-surface2);
}