/**
 * P8s Admin Panel - Minimal Styles
 * 
 * Clean, minimal interface with light/dark mode support.
 */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-hover: #fff7ed;
    /* Orange-50 tint */
    --text-primary: #1c1917;
    /* Warm gray-900 */
    --text-secondary: #57534e;
    /* Warm gray-600 */
    --border-color: #e7e5e4;
    /* Warm gray-200 */

    /* Fire Palette - Light Mode */
    --primary: #ea580c;
    /* Orange-600 */
    --primary-text: #ffffff;
    --primary-hover: #c2410c;
    /* Orange-700 */

    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --success: #059669;
    --success-bg: #ecfdf5;

    --radius: 8px;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
}

[data-theme="dark"] {
    --bg-primary: #0c0a09;
    /* Warm gray-950 */
    --bg-secondary: #1c1917;
    /* Warm gray-900 */
    --bg-hover: #292524;
    /* Warm gray-800 */
    --text-primary: #fafaf9;
    /* Warm gray-50 */
    --text-secondary: #a8a29e;
    /* Warm gray-400 */
    --border-color: #292524;
    /* Warm gray-800 */

    /* Fire Palette - Dark Mode */
    --primary: #f97316;
    /* Orange-500 */
    --primary-text: #ffffff;
    --primary-hover: #ea580c;
    /* Orange-600 */

    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.admin-panel {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
    display: flex;
    flex-direction: column;
}

.admin-sidebar.collapsed+.admin-main {
    margin-left: var(--sidebar-collapsed);
}

/* Layout Wrappers */
.list-wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.list-wrapper .admin-list {
    flex: 1;
    width: 0;
    /* Critical for flex child to shrink properly */
    min-width: 0;
    padding-right: 24px;
    /* Add some space between list and sidebar */
}

.filter-sidebar {
    width: 280px;
    min-width: 280px;
    /* Prevent shrinking */
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    padding: 32px 24px;
    flex-shrink: 0;
    /* Ensure it stays fixed width */
}

.filter-group {
    margin-bottom: 24px;
}

.filter-group h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}

.filter-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-group li {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.filter-group li a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    padding: 2px 0;
    transition: color 0.15s;
}

.filter-group li a:hover {
    color: var(--primary);
}

.filter-group li.selected a {
    color: var(--primary);
    font-weight: 600;
}

/* Sortable Headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.data-table th.sortable:hover {
    background: var(--bg-hover);
}

.sort-indicator {
    display: inline-block;
    margin-left: 6px;
    color: var(--primary);
    font-size: 1.1em;
}

/* Views Container */
.admin-list,
.admin-form,
.admin-dashboard {
    padding: 32px;
    width: 100%;
}

.admin-form {
    background: var(--bg-primary);
    /* border: 1px solid var(--border-color); */
    /* Optional: remove border if it fills page */
    /* border-radius: var(--radius); */
    /* overflow: hidden; */
    /* max-width: 800px; REMOVED */
    /* margin: 0 auto; REMOVED */
}

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

.list-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width 0.2s ease;
}

.admin-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
}


.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 2px;
    transition: all 0.1s;
}

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

.nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* Global Header */
.global-header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Content Area */
.content-wrapper {
    padding: 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Typography */
h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 24px 0;
    letter-spacing: -0.01em;
}

/* Dashboard */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
    margin-top: 16px;
}

.dashboard-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-4px);
}

.dashboard-card .card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--primary);
    margin-bottom: 4px;
    transition: all 0.2s;
}

.dashboard-card:hover .card-icon {
    background: var(--primary);
    color: var(--primary-text);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
}

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

/* Tables */
/* Tables */
.data-table-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-primary);
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

.data-table tr:hover td {
    background: var(--bg-hover);
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-page {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.1s;
}

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

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

.page-size-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    background: transparent;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: transparent;
}

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

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

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

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

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    padding: 8px;
    color: var(--text-secondary);
}

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

/* Forms Container */
/* Forms Container */
/* .admin-form style is now handled in Layout section above */

.form-header {
    background: var(--bg-secondary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: var(--radius) var(--radius) 0 0;
    /* Add radius if we keep the card look */
}

/* We want the form to look integrated, so we might wrap the inner form in a card if needed */
.dynamic-form {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 32px;
}

/* Fix form header to match */
.form-header {
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.form-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
}

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

/* Forms */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.dynamic-form {
    padding: 24px;
}

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

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

.checkbox-group {
    display: flex;
    align-items: center;
}

/* Search Box */
.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    /* Space for icon */
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 18px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

/* Custom Checkboxes */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
    border-color: var(--primary);
}

.help-text {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Login */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    padding: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Utilities */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

/* Badges */
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

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

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

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius);
}

.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Notification */
.notification {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 12px 24px;
    border-radius: var(--radius);
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    max-width: 90%;
    width: auto;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.notification.success {
    background: var(--success);
    color: white;
}

.notification.error {
    background: var(--danger);
    color: white;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    border: 1px solid var(--border-color);
}

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

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

.modal-body {
    padding: 0;
    /* DynamicForm has its own padding */
    overflow-y: auto;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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