/* Modern Blog Admin UI - Thai-optimized */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-sm);
}

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

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

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

.btn-outline {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--border-light);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--border-light);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-content {
    padding: 2rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 1024px) {
    .grid-cols-5 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-cols-5,
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 { grid-template-columns: 1fr; }
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

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

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

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

.admin-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user-info {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    min-width: 250px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

@media (max-width: 1024px) {
    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.admin-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.admin-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.admin-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.admin-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Login Form */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.login-form {
    background: var(--surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

.login-divider {
    position: relative;
    margin: 1.5rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    background: var(--surface);
    padding: 0 1rem;
}

/* Loading */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid transparent;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.loading-text {
    color: white;
    font-weight: 500;
}

/* Status badges */
.status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.status-published {
    background: #dcfce7;
    color: #166534;
}

.status-draft {
    background: #fef3c7;
    color: #92400e;
}

.status-approved {
    background: #dcfce7;
    color: #166534;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-spam {
    background: #fee2e2;
    color: #991b1b;
}

/* List items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--border-light);
}

.item-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

.item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.text-center { text-align: center; }

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    position: relative;
    z-index: 2001;
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
}

/* Image Gallery Styles */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.image-item {
    position: relative;
    background: var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.image-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.image-item.selected {
    border-color: var(--accent);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-item:hover .image-item-overlay,
.image-item.selected .image-item-overlay {
    opacity: 1;
}

.image-item-actions {
    display: flex;
    gap: 0.5rem;
}

.image-item-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Quill Editor Custom Styles */
.ql-container {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif !important;
}

.ql-editor {
    line-height: 1.7;
    font-size: 16px;
}

.ql-editor h1 { font-size: 2rem; font-weight: 700; }
.ql-editor h2 { font-size: 1.5rem; font-weight: 600; }
.ql-editor h3 { font-size: 1.25rem; font-weight: 600; }

.ql-toolbar.ql-snow {
    background: var(--border-light);
}

.btn-gallery:hover {
    background: var(--border-light) !important;
}

/* Drag & Drop Styles */
.drag-over {
    border-color: var(--accent) !important;
    background: rgba(59, 130, 246, 0.05) !important;
}

.upload-section.drag-over {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-menu {
        flex-wrap: wrap;
    }
    
    .list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .item-actions {
        justify-content: flex-end;
    }

    .modal {
        padding: 1rem;
    }

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

    .modal-body {
        padding: 1rem;
        max-height: 70vh;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }

    .ql-toolbar.ql-snow {
        padding: 8px;
    }

    .ql-formats {
        margin-right: 8px !important;
    }

    /* Mobile Post Editor Styles */
    .grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

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

    .admin-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Mobile Quill Editor */
    .ql-toolbar.ql-snow .ql-formats {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .ql-toolbar.ql-snow select {
        max-width: 120px;
    }

    /* Sticky actions for mobile */
    .mobile-sticky-actions {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 1rem;
        display: flex;
        gap: 0.5rem;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .mobile-sticky-actions .btn {
        flex: 1;
        font-size: 0.875rem;
        padding: 0.75rem;
    }

    /* Hide regular action buttons on mobile */
    @media (max-width: 768px) {
        .admin-header > div:last-child {
            display: none;
        }
    }
}