/* ══════════════════════════════════════
   PALM MANAGEMENT PORTAL — STYLES
   Dark-themed dashboard
   ══════════════════════════════════════ */

:root {
    --p-bg: #0f1117;
    --p-surface: #1a1d27;
    --p-surface-hover: #22252f;
    --p-border: #2a2d3a;
    --p-border-light: #353849;
    --p-text: #e4e5ea;
    --p-text-muted: #8b8fa3;
    --p-text-dim: #6b6f82;
    --p-primary: #2D4A3E;
    --p-primary-light: #3a6354;
    --p-primary-hover: #3d5e50;
    --p-accent: #C4704B;
    --p-accent-hover: #d48058;
    --p-success: #34d399;
    --p-success-bg: rgba(52,211,153,0.1);
    --p-warning: #fbbf24;
    --p-warning-bg: rgba(251,191,36,0.1);
    --p-danger: #f87171;
    --p-danger-bg: rgba(248,113,113,0.1);
    --p-info: #60a5fa;
    --p-info-bg: rgba(96,165,250,0.1);
    --p-sidebar-w: 260px;
    --p-topbar-h: 60px;
    --p-radius: 8px;
    --p-radius-sm: 6px;
    --p-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --p-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body.portal-body {
    font-family: var(--p-font);
    background: var(--p-bg);
    color: var(--p-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--p-accent); text-decoration: none; }
a:hover { color: var(--p-accent-hover); }

/* ── Auth Pages (login, register, etc.) ── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: var(--p-bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 12px;
    padding: 2.5rem;
}

.auth-logo {
    display: block;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--p-text);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

.auth-logo span { color: var(--p-accent); }

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-card .auth-subtitle {
    color: var(--p-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--p-text-muted);
    margin-bottom: 0.35rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--p-bg);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius-sm);
    color: var(--p-text);
    font-family: var(--p-font);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

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

.form-textarea { min-height: 100px; resize: vertical; }
.form-select { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--p-text-dim);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.78rem;
    color: var(--p-danger);
    margin-top: 0.25rem;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--p-radius-sm);
    font-family: var(--p-font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg { width: 16px; height: 16px; }

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

.btn-accent {
    background: var(--p-accent);
    color: #fff;
}
.btn-accent:hover { background: var(--p-accent-hover); color: #fff; }

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

.btn-danger { background: var(--p-danger); color: #fff; }
.btn-danger:hover { background: #ef4444; color: #fff; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Flash Messages ── */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--p-radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: flashIn 0.3s ease;
}

@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.flash-success { background: var(--p-success-bg); color: var(--p-success); border: 1px solid rgba(52,211,153,0.2); }
.flash-error { background: var(--p-danger-bg); color: var(--p-danger); border: 1px solid rgba(248,113,113,0.2); }
.flash-warning { background: var(--p-warning-bg); color: var(--p-warning); border: 1px solid rgba(251,191,36,0.2); }
.flash-info { background: var(--p-info-bg); color: var(--p-info); border: 1px solid rgba(96,165,250,0.2); }

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
    padding: 0 0.25rem;
}
.flash-close:hover { opacity: 1; }

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

/* ── Sidebar ── */
.sidebar {
    width: var(--p-sidebar-w);
    background: var(--p-surface);
    border-right: 1px solid var(--p-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--p-border);
}

.sidebar-logo {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--p-text);
    display: block;
}

.sidebar-logo span { color: var(--p-accent); }

.sidebar-role {
    font-size: 0.75rem;
    color: var(--p-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--p-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--p-radius-sm);
    color: var(--p-text-muted);
    font-size: 0.875rem;
    transition: all 0.15s;
}

.sidebar-link:hover {
    background: var(--p-surface-hover);
    color: var(--p-text);
}

.sidebar-link.active {
    background: var(--p-primary);
    color: #fff;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-link .badge-count {
    margin-left: auto;
    background: var(--p-accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-weight: 600;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--p-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: var(--p-text-dim);
    text-transform: capitalize;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--p-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    height: var(--p-topbar-h);
    background: var(--p-surface);
    border-bottom: 1px solid var(--p-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--p-text-dim);
}

.topbar-breadcrumb a { color: var(--p-text-muted); }
.topbar-breadcrumb a:hover { color: var(--p-text); }

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

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--p-text);
    cursor: pointer;
    padding: 0.5rem;
}

.topbar-toggle svg { width: 22px; height: 22px; }

/* ── Content Area ── */
.content {
    flex: 1;
    padding: 2rem;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ── Cards ── */
.card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 1.5rem;
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.green { background: var(--p-success-bg); color: var(--p-success); }
.stat-icon.blue { background: var(--p-info-bg); color: var(--p-info); }
.stat-icon.orange { background: var(--p-warning-bg); color: var(--p-warning); }
.stat-icon.red { background: var(--p-danger-bg); color: var(--p-danger); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--p-text-muted);
    margin-top: 0.15rem;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--p-border);
    border-radius: var(--p-radius);
    background: var(--p-surface);
}

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

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--p-text-dim);
    background: var(--p-bg);
    border-bottom: 1px solid var(--p-border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--p-border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--p-surface-hover); }

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

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-success { background: var(--p-success-bg); color: var(--p-success); }
.badge-warning { background: var(--p-warning-bg); color: var(--p-warning); }
.badge-danger { background: var(--p-danger-bg); color: var(--p-danger); }
.badge-info { background: var(--p-info-bg); color: var(--p-info); }
.badge-muted { background: rgba(139,143,163,0.1); color: var(--p-text-muted); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border-radius: var(--p-radius-sm);
    font-size: 0.85rem;
    color: var(--p-text-muted);
}

.pagination a:hover { background: var(--p-surface-hover); color: var(--p-text); }
.pagination .active { background: var(--p-primary); color: #fff; }
.pagination .disabled { opacity: 0.3; pointer-events: none; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--p-text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--p-text-dim);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--p-text);
    margin-bottom: 0.5rem;
}

.empty-state p { font-size: 0.875rem; margin-bottom: 1rem; }

/* ── Auth form link ── */
.auth-links {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--p-text-muted);
}

.auth-links a { color: var(--p-accent); }
.auth-links a:hover { text-decoration: underline; }

.auth-remember {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: var(--p-text-muted);
}

.auth-remember label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

/* ── Detail grids ── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.detail-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--p-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.detail-item .value {
    font-size: 0.95rem;
    color: var(--p-text);
}

/* ── Utility ── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--p-text-muted); }
.text-sm { font-size: 0.85rem; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ── Mobile ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar-overlay.open { display: block; }

    .main-content { margin-left: 0; }
    .topbar-toggle { display: block; }
    .content { padding: 1rem; }

    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 1.5rem; }
}
