/* ==========================================================================
   PQWA — Stylesheet
   RTL. القيم في :root عشان التعديل يكون من مكان واحد.
   ========================================================================== */

:root {
    --brand:        #128c7e;
    --brand-dark:   #0d6f63;
    --brand-light:  #e6f4f1;
    --text:         #1f2937;
    --text-muted:   #6b7280;
    --border:       #e5e7eb;
    --bg:           #ffffff;
    --bg-alt:       #f9fafb;
    --danger:       #dc2626;
    --success:      #059669;
    --radius:       10px;
    --shadow:       0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .04);
    --container:    1140px;
}

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

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-dark);
}

code {
    font-family: "Consolas", "Courier New", monospace;
    font-size: .9em;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    direction: ltr;
    display: inline-block;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

/* ------------------------------------------------------------- Header --- */

.header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 66px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.logo i {
    color: var(--brand);
}

.nav-links {
    display: flex;
    gap: 26px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--brand);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: 0;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
}

/* --------------------------------------------------------------- Hero --- */

.hero {
    padding: 84px 0 72px;
    text-align: center;
    background:
        radial-gradient(circle at 50% 0%, var(--brand-light), transparent 62%),
        var(--bg);
}

.hero-compact {
    padding: 64px 0;
    background: var(--bg);
}

.hero h1 {
    margin: 0 0 12px;
    font-size: 46px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.5px;
}

.hero-compact h1 {
    font-size: 34px;
}

.hero .tagline {
    margin: 0 0 18px;
    font-size: 21px;
    color: var(--brand);
    font-weight: 600;
}

.hero .lead {
    margin: 0 auto;
    max-width: 640px;
    color: var(--text-muted);
}

.hero-actions {
    margin-top: 32px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------ Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

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

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

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

.btn-outline:hover {
    border-color: var(--brand);
    color: var(--brand);
}

/* --------------------------------------------------------------- Grid --- */

.features {
    padding: 72px 0;
    background: var(--bg-alt);
}

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

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 24px;
    box-shadow: var(--shadow);
}

.card i {
    font-size: 24px;
    color: var(--brand);
}

.card h3 {
    margin: 12px 0 6px;
    font-size: 18px;
    font-weight: 700;
}

.card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
}

/* -------------------------------------------------------------- Table --- */

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

.table th,
.table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    width: 40%;
}

.table tr:last-child th,
.table tr:last-child td {
    border-bottom: 0;
}

/* -------------------------------------------------------------- Flash --- */

.flash-message {
    padding: 12px 0;
    font-size: 15px;
}

.flash-message > .container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash-success {
    background: #ecfdf5;
    color: var(--success);
    border-bottom: 1px solid #a7f3d0;
}

.flash-error {
    background: #fef2f2;
    color: var(--danger);
    border-bottom: 1px solid #fecaca;
}

.flash-close {
    margin-right: auto;
    background: none;
    border: 0;
    font-size: 20px;
    color: inherit;
    cursor: pointer;
    line-height: 1;
}

/* ------------------------------------------------------------- Footer --- */

.footer {
    padding: 28px 0;
    border-top: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 14px;
}

.footer-bottom {
    text-align: center;
}

.footer-bottom p {
    margin: 0;
}

/* ---------------------------------------------------------- Responsive --- */

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav-links.is-open {
        display: flex;
        position: absolute;
        top: 66px;
        right: 0;
        left: 0;
        flex-direction: column;
        gap: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        padding: 8px 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .hero {
        padding: 56px 0 48px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .hero .tagline {
        font-size: 18px;
    }
}
/* ==========================================================================
   PQWA — Phase 2: users, tenants, auth
   كل الـ classes اللي مabilitéستعملهاش قبل كده.
   ========================================================================== */

/* --------------------------------------------------------- Variables --- */

:root {
    --brand-soft:    #f0faf8;
    --danger-soft:   #fef2f2;
    --warn:          #b45309;
    --warn-soft:     #fffbeb;
    --info:          #0369a1;
    --info-soft:     #f0f9ff;
    --ok:            #047857;
    --space:         20px;
}

/* ------------------------------------------------------------ Navbar --- */

.nav-links a.active {
    color: var(--brand);
}

.nav-cta {
    background: var(--brand);
    color: #fff !important;
    padding: 7px 16px;
    border-radius: var(--radius);
}

.nav-cta:hover {
    background: var(--brand-dark);
}

.nav-user a {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
}

.nav-logout {
    color: var(--danger) !important;
}

.tenant-bar {
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    padding: 8px 0;
}

.tenant-bar .container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tenant-name {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ------------------------------------------------------------ Layout --- */

.main-content {
    padding: 34px 0 60px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.page-head h1 {
    margin: 0 0 4px;
    font-size: 28px;
    font-weight: 800;
}

.page-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
}

.head-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.page-foot {
    margin-top: 22px;
    font-size: 14px;
}

/* ------------------------------------------------------------- Cards --- */

.card-title {
    margin: 0 0 18px;
    font-size: 17px;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-danger {
    border-color: #fecaca;
    background: var(--danger-soft);
}

.card-danger .card-title {
    color: var(--danger);
    border-bottom-color: #fecaca;
}

.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 24px; }

/* ----------------------------------------------------------- Buttons --- */

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

.btn-ghost:hover {
    border-color: var(--brand);
    color: var(--brand);
}

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

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ------------------------------------------------------------ Fields --- */

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="search"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
}

.field textarea {
    resize: vertical;
    min-height: 80px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.field input:disabled,
.field select:disabled {
    background: var(--bg-alt);
    color: var(--text-muted);
    cursor: not-allowed;
}

.field input[type="search"] {
    direction: ltr;
    text-align: left;
}

.req {
    color: var(--danger);
    font-weight: 700;
}

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-muted);
}

.field-note {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text-muted);
}

.field-error {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: var(--danger);
    font-weight: 600;
}

.field-check label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 500;
    cursor: pointer;
}

.field-check input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--brand);
    cursor: pointer;
}

.field-full {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 22px;
}

.form-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    max-width: 780px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.rule {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0 18px;
}

.static-value {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ------------------------------------------------------------ Alerts --- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert i {
    margin-top: 3px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: var(--ok);
    border-color: #a7f3d0;
}

.alert-info {
    background: var(--info-soft);
    color: var(--info);
    border-color: #bae6fd;
}

.alert-warn {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: #fde68a;
}

/* ------------------------------------------------------------ Badges --- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    direction: rtl;
}

.badge-owner  { background: #ede9fe; color: #6d28d9; }
.badge-admin  { background: var(--brand-light); color: var(--brand-dark); }
.badge-agent  { background: #f3f4f6; color: #4b5563; }
.badge-active { background: #ecfdf5; color: var(--ok); }
.badge-invited{ background: var(--warn-soft); color: var(--warn); }
.badge-disabled,
.badge-none    { background: #f3f4f6; color: #6b7280; }
.badge-you     { background: #e0f2fe; color: #0369a1; margin-right: 6px; }

/* ------------------------------------------------------------- Stats --- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-grid-inline {
    margin-bottom: 0;
}

.stat-card-sm {
    padding: 12px 14px;
}

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

.stat-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
}

/* ------------------------------------------------------------ Tables --- */

.table-wrap {
    overflow-x: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.data-table th,
.data-table td {
    padding: 13px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background: var(--bg-alt);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

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

.data-table tbody tr:hover {
    background: var(--brand-soft);
}

.col-actions {
    width: 1%;
    white-space: nowrap;
}

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

.row-muted td {
    opacity: .72;
}

.truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 11px;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.user-name:hover {
    color: var(--brand);
}

.user-email {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.row-actions a,
.row-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 0;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

.row-actions a:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
}

.row-actions button:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.row-actions button.danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.inline-form {
    display: inline;
    margin: 0;
}

/* ---------------------------------------------------------- Filters --- */

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filter-bar input[type="search"] {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 15px;
    background: var(--bg);
}

.filter-bar select {
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    background: var(--bg);
}

.filter-bar .btn {
    padding: 9px 18px;
    font-size: 14px;
    background: var(--brand);
    color: #fff;
}

.filter-bar .btn-ghost {
    background: var(--bg);
    color: var(--text-muted);
}

/* ----------------------------------------------------- Empty states --- */

.empty-state {
    text-align: center;
    padding: 56px 20px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    color: var(--border);
    margin-bottom: 14px;
}

.empty-state p {
    margin: 0;
    font-size: 15px;
}

/* ------------------------------------------------------ Pagination --- */

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.page-link:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.page-link.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.page-gap {
    color: var(--text-muted);
    padding: 0 4px;
}

/* ---------------------------------------------------------- Details --- */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 22px;
    align-items: start;
}

.detail-list {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 11px 18px;
}

.detail-list dt {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.detail-list dd {
    margin: 0;
    font-size: 15px;
    word-break: break-word;
}

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

.ok-text {
    color: var(--ok);
    font-size: 14px;
}

.warn-text {
    color: var(--warn);
    font-size: 14px;
}

/* ------------------------------------------------------ Auth pages --- */

.auth-body {
    background:
        radial-gradient(circle at 50% -10%, var(--brand-light), transparent 55%),
        var(--bg-alt);
    min-height: 100vh;
}

.auth-wrap {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 48px 20px 60px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 26px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.auth-logo i {
    color: var(--brand);
}

.auth-tagline {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 15px;
}

.auth-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
}

.auth-title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    text-align: center;
}

.auth-sub {
    margin: 0 0 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
}

.auth-form .btn {
    margin-top: 8px;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
}

.auth-body .flash-message {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 13px 16px;
    margin-bottom: 18px;
    font-size: 14px;
}

.auth-body .flash-message > .container {
    padding: 0;
}

/* ------------------------------------------------------ Responsive --- */

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-head h1 {
        font-size: 23px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 11px;
        font-size: 14px;
    }

    .nav-user .nav-name {
        display: none;
    }

    .auth-card {
        padding: 26px 20px;
    }
}