/* CMS Styles - Dhrub Foundation */

:root {
    --primary: hsl(160, 84%, 39%);
    --primary-light: hsl(160, 84%, 95%);
    --primary-dark: hsl(160, 84%, 30%);
    --background: hsl(210, 20%, 96%);
    --card: hsl(0, 0%, 100%);
    --text: hsl(220, 20%, 10%);
    --text-muted: hsl(215, 16%, 47%);
    --border: hsl(214, 32%, 91%);
    --destructive: hsl(0, 84%, 60%);
    --warning: hsl(38, 92%, 50%);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Outfit', 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.cms-sidebar {
    width: var(--sidebar-width);
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.logo-text .brand {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}

.logo-text .subtitle {
    display: block;
    font-size: 0.75rem;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

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

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

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

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

/* Main Content */
.cms-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.cms-header {
    height: var(--header-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}

/* Alert */
#alert-container {
    padding: 0 24px;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid hsl(160, 84%, 85%);
}

.alert-error {
    background: hsl(0, 84%, 95%);
    color: hsl(0, 84%, 40%);
    border: 1px solid hsl(0, 84%, 85%);
}

/* Content Sections */
.content-section {
    padding: 24px;
}

.content-section.hidden {
    display: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    min-width: 280px;
}

.search-box i {
    color: var(--text-muted);
}

.search-box input {
    border: none;
    outline: none;
    font-size: 0.9rem;
    width: 100%;
    font-family: inherit;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-group select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--card);
    cursor: pointer;
    font-family: inherit;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.item-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s ease;
}

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

.item-image {
    height: 160px;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.item-image i {
    font-size: 3rem;
    color: var(--border);
}

.item-body {
    padding: 16px;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.item-category {
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.item-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.item-status.published {
    background: hsl(160, 84%, 95%);
    color: hsl(160, 84%, 30%);
}

.item-status.draft {
    background: hsl(38, 92%, 95%);
    color: hsl(38, 92%, 35%);
}

.item-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-excerpt {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.item-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.item-actions button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.item-actions button.delete:hover {
    border-color: var(--destructive);
    color: var(--destructive);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    background: var(--card);
    transition: all 0.2s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.upload-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

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

.media-item:hover {
    border-color: var(--primary);
}

.media-item.selected {
    border-color: var(--primary);
}

.media-item.selected::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

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

.media-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 24px 12px 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.media-item:hover .media-item-overlay {
    opacity: 1;
}

.media-item-name {
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading & Empty State */
.loading-state,
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.loading-state i,
.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

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

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

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

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

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

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

.btn-danger:hover {
    background: hsl(0, 84%, 50%);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-large {
    max-width: 800px;
}

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

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-row .form-group.flex-2 {
    flex: 2;
}

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

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--destructive);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Image Picker */
.image-picker {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.image-preview {
    width: 200px;
    height: 140px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.image-preview i {
    font-size: 2rem;
    color: var(--border);
    margin-bottom: 8px;
}

.image-preview span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Media Picker Modal */
.media-picker-upload {
    text-align: center;
    margin-bottom: 20px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.media-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.delete-message {
    text-align: center;
    padding: 16px 0;
    color: var(--text-muted);
}

/* TinyMCE Wrapper */
.tox-tinymce {
    border-radius: var(--radius) !important;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .cms-sidebar {
        transform: translateX(-100%);
    }
    
    .cms-sidebar.open {
        transform: translateX(0);
    }
    
    .cms-main {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .image-picker {
        flex-direction: column;
    }
    
    .image-preview {
        width: 100%;
    }
}
