@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette - Dark Mode (Zinc) */
    --bg-base: #09090b; /* zinc-950 */
    --bg-surface: #18181b; /* zinc-900 */
    --bg-hover: #27272a; /* zinc-800 */
    --bg-active: #3f3f46; /* zinc-700 */
    
    --text-primary: #f4f4f5; /* zinc-100 */
    --text-secondary: #a1a1aa; /* zinc-400 */
    --text-muted: #71717a; /* zinc-500 */
    
    --border-color: #27272a; /* zinc-800 */
    --border-focus: #3f3f46; /* zinc-700 */
    
    --primary-color: #f59e0b; /* amber-500 (Filament primary) */
    --primary-hover: #d97706; /* amber-600 */
    
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-text: #10b981;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-text: #f59e0b;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-text: #ef4444;

    --sidebar-width: 280px;
    --header-height: 64px;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-base);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 40;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    border-bottom: 1px solid transparent; /* matches header layout */
}

.sidebar-header span {
    color: var(--primary-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

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

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

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 1rem 0 0.5rem 1rem;
}

/* Main Content */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-base);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container svg {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-input {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    font-size: 0.875rem;
    width: 250px;
    transition: all 0.2s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-surface);
    border: 2px solid var(--border-color);
    object-fit: cover;
    cursor: pointer;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

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

/* Sections (for SPA functionality) */
.section-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section-content.active {
    display: block;
}

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

/* Data Table Container */
.table-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

.table-responsive {
    overflow-x: auto;
}

.filament-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.filament-table th {
    background-color: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.filament-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.filament-table tr:last-child td {
    border-bottom: none;
}

.filament-table tr {
    transition: background-color 0.2s ease;
}

.filament-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Table specific cells */
.cell-title {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cell-image {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background-color: var(--success-bg); color: var(--success-text); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger-text); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

/* Action Buttons in Table */
.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Table Pagination Area */
.table-pagination {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.page-btn.active {
    background-color: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--bg-active);
}

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

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.stat-title {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.stat-change {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive { color: var(--success-text); }
.stat-change.negative { color: var(--danger-text); }

/* Form Elements (for filters/search) */
.filter-dropdown {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 0.5rem 2rem 0.5rem 1rem;
    font-size: 0.875rem;
    appearance: none;
    outline: none;
    cursor: pointer;
    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='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.filter-dropdown:focus {
    border-color: var(--primary-color);
}

/* Mobile Sidebar Toggle */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .mobile-toggle {
        display: block;
    }
}

/* Auth Layout (Login Page) */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-base);
    padding: 1rem;
}

.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--primary-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-input {
    width: 100%;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.auth-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

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

.auth-error {
    color: var(--danger-text);
    background-color: var(--danger-bg);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: none;
}

/* Profile Dropdown */
.profile-menu-container {
    position: relative;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 220px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 50;
    padding: 0.5rem 0;
}

.profile-dropdown.show {
    display: flex;
}

.dropdown-header {
    padding: 0.5rem 1rem;
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item i, .dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-item.text-danger {
    color: var(--danger-text);
}

.dropdown-item.text-danger:hover {
    background-color: var(--danger-bg);
}

/* Nested Navigation */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-parent {
    justify-content: space-between;
    width: 100%;
}

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

.nav-parent .chevron {
    transition: transform 0.3s ease;
    width: 16px;
    height: 16px;
}

.nav-group.open .nav-parent .chevron {
    transform: rotate(180deg);
}

.nav-children {
    display: none;
    flex-direction: column;
    padding-left: 1.5rem;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.nav-group.open .nav-children {
    display: flex;
}

.nav-children .nav-item {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* Code Editor */
.code-editor {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background-color: var(--bg-base);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    width: 100%;
    resize: vertical;
    outline: none;
    white-space: pre;
}

.code-editor:focus {
    border-color: var(--primary-color);
}

/* Dynamic Widgets */
.widget-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

.widget-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.widget-card-title {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.widget-delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.widget-delete-btn:hover {
    background: var(--danger-text);
    color: #fff;
}
