/* public/assets/css/app.css */

/* ========= CSS Variables ========= */
:root {
    --bg-body: #f5f7fb;
    --bg-panel: #ffffff;
    --bg-soft: #f9fafb;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --accent-strong: #1d4ed8;
    --text-main: #0f172a;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --radius-lg: 18px;
    --shadow-soft: 0 16px 32px rgba(15, 23, 42, 0.08);
    --sidebar-width: 260px;
}

/* ========= Reset / Base ========= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-main);
    background: var(--bg-body);
}

/* ========= Global page loader ========= */
.page-loader {
    position: fixed;
    inset: 0;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity .3s ease;
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.page-loader .spinner {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--accent);
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========= AUTH / LOGIN ========= */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
    background: radial-gradient(circle at top left, #e0f2fe 0, #f5f7fb 40%, #ffffff 100%);
}

.auth-panel {
    margin: auto;
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.97);
    border-radius: 26px;
    box-shadow: var(--shadow-soft);
    padding: 26px 24px 22px;
    backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.auth-logo-circle {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: radial-gradient(circle at 20% 20%, #38bdf8, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #f9fafb;
    font-size: 18px;
}

.auth-title {
    font-size: 20px;
    font-weight: 600;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-form {
    margin-top: 10px;
}

.auth-form .field {
    margin-bottom: 14px;
}

.auth-form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="email"] {
    width: 100%;
    padding: 10px 11px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 14px;
    outline: none;
    background: #f9fafb;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
    background: #ffffff;
}

.auth-form .error-box {
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 12px;
    border: 1px solid #fecaca;
    padding: 8px 10px;
    font-size: 13px;
    margin-bottom: 10px;
}

.auth-form .actions {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-primary {
    border: none;
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb, #22c55e);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 12px 20px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.03);
}

.auth-footer-note {
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Small neutral button style */
.btn-sm {
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
}

.btn-sm-danger {
    border-color: #fecaca;
    background: #fee2e2;
    color: #b91c1c;
}

/* ========= APP SHELL (SIDEBAR + MAIN) ========= */

.app-shell {
    min-height: 100vh;
    display: flex;
}

/* Light sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 16px;
    position: relative;
    z-index: 30;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    box-shadow: 6px 0 20px rgba(15, 23, 42, 0.04);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.sidebar-logo-circle {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: radial-gradient(circle at 25% 20%, #38bdf8, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    color: #f9fafb;
}

.sidebar-company {
    display: flex;
    flex-direction: column;
}

.sidebar-company-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.sidebar-company-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-nav {
    margin-top: 8px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 8px 9px;
    border-radius: 11px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-main);
    margin-bottom: 4px;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.sidebar-nav a span.icon {
    margin-right: 8px;
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, #e0edff, #d1fae5);
    color: var(--accent-strong);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}

/* Sidebar sections + sub-links (Users section etc.) */
.sidebar-section {
    margin-top: 10px;
}

.sidebar-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 4px 4px 4px 9px;
}

.sidebar-subnav {
    margin-top: 3px;
    margin-bottom: 4px;
}

.sidebar-subnav a {
    font-size: 12px;
    padding-left: 26px;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-logout-form {
    margin-top: 8px;
}

.sidebar-logout-form button {
    width: 100%;
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 7px 0;
    font-size: 12px;
    background: #f9fafb;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color .15s ease, box-shadow .15s ease;
}

.sidebar-logout-form button:hover {
    background: #e5f0ff;
    box-shadow: 0 3px 10px rgba(148, 163, 184, 0.4);
}

/* Backdrop for mobile overlay */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
    z-index: 20;
}

/* ========= MAIN AREA ========= */

.main {
    flex: 1;
    padding: 18px 18px 24px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: radial-gradient(circle at top left, #eef2ff 0, #f5f7fb 45%, #ffffff 100%);
}

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

.main-title-block h1 {
    margin: 0;
    font-size: 21px;
}

.main-title-block p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* Right side: search + user badge */
.main-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    padding: 7px 12px;
    border-radius: 999px;
    background: #eef2ff;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-badge-role {
    padding: 2px 7px;
    border-radius: 999px;
    background: #dbeafe;
    font-size: 11px;
}

/* Mobile sidebar toggle banner button */
.mobile-sidebar-toggle {
    display: none;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, #ffffff, #e5f0ff);
    padding: 7px 12px;
    font-size: 13px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-main);
    box-shadow: 0 8px 20px rgba(148, 163, 184, 0.35);
}

.mobile-sidebar-toggle .icon {
    font-size: 15px;
}

/* ========= TOP BAR SEARCH ========= */

.global-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f9fafb;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.global-search-icon {
    font-size: 14px;
    color: var(--text-muted);
}

.global-search-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-main);
    min-width: 160px;
}

.global-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

/* ===== Global search results panel (dashboard) ===== */

.global-search-results {
    margin-bottom: 14px;
    display: none;
}

.global-search-results.visible {
    display: block;
}

.global-search-results-card {
    background: var(--bg-panel);
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 10px 12px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
}

.global-search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.global-search-results-header .q {
    font-weight: 500;
    color: var(--text-main);
}

.global-search-results-groups {
    display: grid;
    gap: 8px;
}

.global-search-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.global-search-item {
    padding: 4px 0;
    border-top: 1px dashed rgba(148, 163, 184, 0.5);
}

.global-search-item:first-of-type {
    border-top: none;
}

.global-search-item-main {
    font-size: 12px;
    font-weight: 500;
}

.global-search-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.global-search-results-empty {
    font-size: 12px;
    color: var(--text-muted);
}

/* ========= CARDS / GRID ========= */

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 16px 16px 14px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.card-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.card-value {
    font-size: 21px;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ========= TABLE / BADGES ========= */

.users-toolbar {
    margin-top: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.users-count {
    font-size: 12px;
    color: var(--text-muted);
}

.users-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #f9fafb;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.users-table thead {
    background: #eef2ff;
}

.users-table th,
.users-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    white-space: nowrap;
}

.users-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
}

.badge-role-admin {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-role-user {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-status-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-status-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.users-error {
    margin-bottom: 8px;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 12px;
    border: 1px solid #fecaca;
    padding: 7px 9px;
    font-size: 12px;
}

/* ========= MODAL (User create/edit) ========= */

.user-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.user-modal-backdrop.show {
    display: flex;
}

.user-modal {
    width: min(420px, 100% - 32px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    padding: 16px 16px 14px;
}

.user-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.user-modal-title {
    font-size: 16px;
    font-weight: 600;
}

.user-modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}

.user-modal-form .field {
    margin-bottom: 10px;
}

.user-modal-form label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.user-modal-form input,
.user-modal-form select {
    width: 100%;
    padding: 8px 9px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
}

.user-modal-form input:focus,
.user-modal-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
    background: #ffffff;
}

.user-modal-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.user-modal-error {
    margin-top: 4px;
    font-size: 12px;
    color: #b91c1c;
}

/* ========= Responsive ========= */

@media (max-width: 900px) {
    .app-shell {
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform .24s ease;
        max-width: var(--sidebar-width);
        box-shadow: 14px 0 38px rgba(15, 23, 42, 0.15);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .main-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .main-header-right {
        justify-content: space-between;
    }

    .global-search {
        flex: 1;
    }

    .global-search-input {
        width: 100%;
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
        justify-content: space-between;
    }
}

@media (min-width: 901px) {
    .sidebar-backdrop {
        display: none;
    }
}
/* Collapsible subnav (for Customers) */
.sidebar-subnav.collapsed {
    display: none;
}

/* Optional: rotate chevron when open */
.sidebar-nav [data-sidebar-toggle] .chevron {
    transition: transform .18s ease;
}
.sidebar-nav [data-sidebar-toggle].sidebar-toggle-open .chevron {
    transform: rotate(90deg);
}
