/**
 * LiteCMS Admin - Modern UI
 * Inspired by shadcn/ui & Radix
 */

:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --success: 142 76% 36%;
    --warning: 38 92% 50%;
    --radius: 0.5rem;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px 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);
    --sidebar-width: 260px;
    --header-height: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: 240 10% 3.9%;
        --foreground: 0 0% 98%;
        --card: 240 10% 3.9%;
        --card-foreground: 0 0% 98%;
        --primary: 0 0% 98%;
        --primary-foreground: 240 5.9% 10%;
        --secondary: 240 3.7% 15.9%;
        --secondary-foreground: 0 0% 98%;
        --muted: 240 3.7% 15.9%;
        --muted-foreground: 240 5% 64.9%;
        --accent: 240 3.7% 15.9%;
        --accent-foreground: 0 0% 98%;
        --border: 240 3.7% 15.9%;
        --input: 240 3.7% 15.9%;
        --ring: 240 4.9% 83.9%;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

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

.sidebar {
    width: var(--sidebar-width);
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.025em; }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 150ms ease;
}
.sidebar-link:hover { color: hsl(var(--foreground)); background: hsl(var(--accent)); }
.sidebar-link.active { color: hsl(var(--foreground)); background: hsl(var(--accent)); }
.sidebar-link svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.main-body { flex: 1; padding: 1.5rem; }

/* Typography */
.page-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; }
.page-description { color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.section-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; }
.label { font-size: 0.875rem; font-weight: 500; display: block; margin-bottom: 0.375rem; }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-sm { font-size: 0.75rem; }

/* Cards */
.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid hsl(var(--border)); }
.card-title { font-size: 1rem; font-weight: 600; }
.card-description { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid hsl(var(--border)); background: hsl(var(--muted) / 0.3); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 1rem; height: 1rem; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover:not(:disabled) { background: hsl(var(--accent)); }
.btn-outline { border-color: hsl(var(--border)); background: transparent; }
.btn-outline:hover:not(:disabled) { background: hsl(var(--accent)); }
.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--accent)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-xs { padding: 0.2rem 0.4rem; font-size: 0.65rem; }
.ml-1 { margin-left: 0.25rem; }
.btn-lg { padding: 0.625rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.input, .select, .textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    transition: all 150ms ease;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.textarea { min-height: 100px; resize: vertical; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}
.checkbox-wrapper { display: flex; align-items: center; gap: 0.5rem; }
.checkbox { width: 1rem; height: 1rem; border-radius: 0.25rem; accent-color: hsl(var(--primary)); }
.form-hint { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.375rem; }
.form-error { font-size: 0.75rem; color: hsl(var(--destructive)); margin-top: 0.375rem; }

/* Tables */
.table-wrapper { overflow-x: auto; border: 1px solid hsl(var(--border)); border-radius: 0.75rem; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
    text-align: left;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    padding: 0.75rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--muted) / 0.3);
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid hsl(var(--border)); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: hsl(var(--muted) / 0.3); }
.table-actions { display: flex; gap: 0.25rem; justify-content: flex-end; }

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.badge-success { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.badge-warning { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.badge-destructive { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }

/* Alerts */
.alert { padding: 1rem; border-radius: var(--radius); border: 1px solid hsl(var(--border)); margin-bottom: 1rem; }
.alert-success { background: hsl(var(--success) / 0.1); border-color: hsl(var(--success) / 0.3); color: hsl(var(--success)); }
.alert-error { background: hsl(var(--destructive) / 0.1); border-color: hsl(var(--destructive) / 0.3); color: hsl(var(--destructive)); }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: hsl(var(--foreground) / 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms ease;
}
.modal-backdrop.active { opacity: 1; visibility: visible; }
.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: hsl(var(--card));
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms ease;
}
.modal.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.modal-lg { max-width: 700px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-body { padding: 1.5rem; overflow-y: auto; max-height: calc(85vh - 130px); }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    top: 100%; right: 0;
    min-width: 180px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 150ms ease;
}
.dropdown.active .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(4px); }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
    cursor: pointer;
}
.dropdown-item:hover { background: hsl(var(--accent)); }
.dropdown-item svg { width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); }
.dropdown-divider { height: 1px; background: hsl(var(--border)); margin: 0.25rem 0; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid hsl(var(--border)); }
.tab {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab.active { color: hsl(var(--foreground)); border-bottom-color: hsl(var(--primary)); }
.tab-content { padding: 1.5rem 0; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: hsl(var(--muted-foreground)); }
.empty-state svg { width: 3rem; height: 3rem; margin: 0 auto 1rem; opacity: 0.5; }
.empty-state-title { font-size: 1rem; font-weight: 500; color: hsl(var(--foreground)); margin-bottom: 0.5rem; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.25rem; margin-top: 1.5rem; }
.pagination-btn {
    min-width: 2rem; height: 2rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
}
.pagination-btn:hover { background: hsl(var(--accent)); }
.pagination-btn.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Media Grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.media-item {
    aspect-ratio: 1;
    border-radius: var(--radius);
    border: 2px solid hsl(var(--border));
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: all 150ms ease;
}
.media-item:hover { border-color: hsl(var(--ring)); }
.media-item.selected { border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3); }
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item-icon {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: hsl(var(--muted));
}
.media-item-icon svg { width: 2.5rem; height: 2.5rem; color: hsl(var(--muted-foreground)); }
.media-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, hsl(var(--foreground) / 0.7), transparent);
    opacity: 0;
    transition: opacity 150ms ease;
    display: flex;
    align-items: flex-end;
    padding: 0.5rem;
}
.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; }

/* Folder Tree */
.folder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.folder-item:hover { background: hsl(var(--accent)); }
.folder-item.active { background: hsl(var(--accent)); font-weight: 500; }
.folder-item svg { width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); }
.folder-count { margin-left: auto; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.folder-children { padding-left: 1.25rem; }

/* Toast */
.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 300px;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: slideIn 200ms ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-title { font-weight: 500; margin-bottom: 0.25rem; }
.toast-message { font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.toast-close { cursor: pointer; color: hsl(var(--muted-foreground)); }
.toast-close:hover { color: hsl(var(--foreground)); }

/* Spinner */
.spinner {
    width: 1.25rem; height: 1.25rem;
    border: 2px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Avatar */
.avatar {
    width: 2rem; height: 2rem;
    border-radius: 9999px;
    background: hsl(var(--muted));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

/* Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: hsl(var(--muted) / 0.3);
}
.login-card { width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex !important; }
}
.mobile-menu-btn { display: none; }
