/* WhatsApp Manager Admin Styles */

/* WhatsApp Brand Colors */
:root {
    --whatsapp-green: #25D366;
    --whatsapp-dark-green: #128C7E;
    --whatsapp-light-green: #DCF8C6;
    --whatsapp-gray: #E8E8E8;
}

/* Login and Register Pages */
.login-box, .register-box {
    width: 360px;
    margin: 7% auto;
}

.login-logo, .register-logo {
    font-size: 35px;
    text-align: center;
    margin-bottom: 25px;
    font-weight: 300;
}

.login-logo a, .register-logo a {
    color: var(--whatsapp-green);
    text-decoration: none;
}

.login-card-body, .register-card-body {
    border-radius: 0;
    padding: 20px;
}

.login-box-msg, .register-box-msg {
    margin: 0;
    text-align: center;
    padding-bottom: 20px;
}

/* Client Status Cards */
.client-status-card {
    border-left: 4px solid var(--whatsapp-green);
    transition: all 0.3s ease;
}

.client-status-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.client-status-card.offline {
    border-left-color: #dc3545;
}

.client-status-card.connecting {
    border-left-color: #ffc107;
}

.client-status {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.status-online {
    color: var(--whatsapp-green);
    background-color: rgba(37, 211, 102, 0.1);
}

.status-offline {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.status-connecting {
    color: #ffc107;
    background-color: rgba(255, 193, 7, 0.1);
}

/* WhatsApp Branded Buttons */
.btn-whatsapp {
    background-color: var(--whatsapp-green);
    border-color: var(--whatsapp-green);
    color: white;
}

.btn-whatsapp:hover {
    background-color: var(--whatsapp-dark-green);
    border-color: var(--whatsapp-dark-green);
    color: white;
}

/* Dashboard Stats */
.info-box {
    background: #fff;
    border-radius: 0.25rem;
    box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    display: flex;
    margin-bottom: 1rem;
    min-height: 80px;
    padding: 0;
    position: relative;
    width: 100%;
}

.info-box-icon {
    border-radius: 0.25rem 0 0 0.25rem;
    display: flex;
    align-items: center;
    font-size: 1.875rem;
    justify-content: center;
    text-align: center;
    width: 70px;
}

.info-box-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.8;
    flex: 1;
    padding: 0 10px;
}

.info-box-text {
    display: block;
    font-size: 1rem;
    margin-top: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-box-number {
    display: block;
    font-weight: 700;
}

/* Timeline */
.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline > div {
    position: relative;
    margin-bottom: 30px;
}

.timeline > div > i {
    background: #007bff;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    height: 30px;
    left: 15px;
    line-height: 30px;
    position: absolute;
    text-align: center;
    top: 0;
    width: 30px;
}

.timeline > div > .timeline-item {
    background: #fff;
    border-radius: 0.25rem;
    box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    margin-left: 60px;
    margin-top: 0;
    padding: 0;
    position: relative;
}

.timeline > div > .timeline-item > .time {
    color: #999;
    float: right;
    font-size: 12px;
    padding: 10px;
}

.timeline > div > .timeline-item > .timeline-header {
    color: #495057;
    font-size: 16px;
    line-height: 1.1;
    margin: 0;
    padding: 10px;
}

.timeline > div > .timeline-item > .timeline-body {
    padding: 10px;
}

.timeline > div > .timeline-item > .timeline-footer {
    padding: 10px;
}

/* User Menu */
.user-menu .user-image {
    float: left;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin-right: 10px;
    margin-top: -2px;
}

.user-menu .user-header {
    height: 175px;
    padding: 10px;
    text-align: center;
}

.user-menu .user-header img {
    width: 90px;
    height: 90px;
    border: 3px solid rgba(255,255,255,0.2);
}

.user-menu .user-header p {
    margin-top: 10px;
    color: #fff;
}

.user-menu .user-header p > .description {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-top: 5px;
}

.user-menu .user-footer {
    background-color: rgba(0,0,0,0.1);
    padding: 10px;
}

.user-menu .user-footer .btn {
    font-size: 12px;
}

/* Client status card: flip accent border in RTL */
[dir="rtl"] .client-status-card {
    border-left: none;
    border-right: 4px solid var(--whatsapp-green);
}

[dir="rtl"] .client-status-card.offline  { border-right-color: #dc3545; }
[dir="rtl"] .client-status-card.connecting { border-right-color: #ffc107; }

/* ═══════════════════════════════════════════════════════════════════
   RTL — Arabic (ar-SA)
   Full overrides for AdminLTE 3 + Bootstrap 4 + landing page
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. Base ──────────────────────────────────────────────────────── */
[dir="rtl"]          { text-align: right; }
[dir="rtl"] .sidebar { direction: rtl; }

/* ── 1b. Navbar: keep LTR item order so hamburger stays LEFT,
         user/lang/bell stay RIGHT — same muscle memory as LTR.
         Sidebar is still on the RIGHT; only the flex order is LTR. ── */
[dir="rtl"] .main-header .navbar {
    direction: ltr;
}

/* Re-apply RTL text direction inside each dropdown so Arabic text
   renders correctly inside menus that hang from the navbar. */
[dir="rtl"] .main-header .dropdown-menu,
[dir="rtl"] .main-header .navbar-search-block {
    direction: rtl;
    text-align: right;
}

/* With direction:ltr on the navbar, dropdown-menu-right alignment is
   now correct again (right-aligned to the toggle button). */
[dir="rtl"] .main-header .dropdown-menu-right {
    right: 0 !important;
    left: auto !important;
}

/* User panel: avatar is to the LEFT of the name in LTR order — keep it */
[dir="rtl"] .main-header .user-menu .user-image {
    float: left;
    margin-right: 6px;
    margin-left: 0;
}

/* ── 2. AdminLTE Sidebar ──────────────────────────────────────────── */
[dir="rtl"] .main-sidebar {
    right: 0 !important;
    left: auto !important;
}

/* Sidebar slides off to the right when fully collapsed (non–sidebar-mini only).
   Must NOT apply translate to sidebar-mini — it stacks with AdminLTE mini rules
   and clips the bar off the viewport. Mirrors AdminLTE’s :not(.sidebar-mini*) */
[dir="rtl"] body.sidebar-collapse:not(.sidebar-mini):not(.sidebar-mini-md):not(.sidebar-mini-xs) .main-sidebar:not(.sidebar-focused):not(:hover),
[dir="rtl"] body.sidebar-collapse:not(.sidebar-mini):not(.sidebar-mini-md):not(.sidebar-mini-xs) .main-sidebar:not(.sidebar-focused):not(:hover)::before {
    margin-right: -250px !important;
    margin-left: 0 !important;
    transform: translate3d(250px, 0, 0) !important;
}

/* Reset transform when sidebar is open (mobile overlay) */
[dir="rtl"] body.sidebar-open .main-sidebar,
[dir="rtl"] body.sidebar-open .main-sidebar::before {
    transform: translate3d(0, 0, 0) !important;
    margin-right: 0 !important;
}

/* Sidebar mini: icon-only width on collapse — no horizontal translate */
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-sidebar,
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-sidebar:not(:hover),
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-sidebar::before,
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-sidebar:not(:hover)::before,
[dir="rtl"] body.sidebar-mini-md.sidebar-collapse .main-sidebar,
[dir="rtl"] body.sidebar-mini-md.sidebar-collapse .main-sidebar:not(:hover),
[dir="rtl"] body.sidebar-mini-md.sidebar-collapse .main-sidebar::before,
[dir="rtl"] body.sidebar-mini-md.sidebar-collapse .main-sidebar:not(:hover)::before,
[dir="rtl"] body.sidebar-mini-xs.sidebar-collapse .main-sidebar,
[dir="rtl"] body.sidebar-mini-xs.sidebar-collapse .main-sidebar:not(:hover),
[dir="rtl"] body.sidebar-mini-xs.sidebar-collapse .main-sidebar::before,
[dir="rtl"] body.sidebar-mini-xs.sidebar-collapse .main-sidebar:not(:hover)::before {
    margin-right: 0 !important;
    margin-left: 0 !important;
    transform: none !important;
    width: 4.6875rem;
}

/* ── 3. Header & Content margins ─────────────────────────────────── */
[dir="rtl"] .main-header {
    margin-right: 250px !important;
    margin-left: 0 !important;
}

[dir="rtl"] .content-wrapper,
[dir="rtl"] .main-footer {
    margin-right: 250px !important;
    margin-left: 0 !important;
}

/* Collapsed: no sidebar taking space */
[dir="rtl"] body.sidebar-collapse .main-header,
[dir="rtl"] body.sidebar-collapse .content-wrapper,
[dir="rtl"] body.sidebar-collapse .main-footer {
    margin-right: 0 !important;
}

/* Mini-collapsed: sidebar still visible at icon width */
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-header,
[dir="rtl"] body.sidebar-mini.sidebar-collapse .content-wrapper,
[dir="rtl"] body.sidebar-mini.sidebar-collapse .main-footer {
    margin-right: 4.6875rem !important;
}

/* ── 4. Sidebar internals ─────────────────────────────────────────── */
[dir="rtl"] .nav-icon {
    margin-right: 0 !important;
    margin-left: 0.5rem;
}

/* Treeview arrow: flip to left side */
[dir="rtl"] .nav-sidebar .nav-item > .nav-link > .right,
[dir="rtl"] .nav-sidebar .nav-item > .nav-link > p > .right {
    float: left !important;
}

/* Brand-link border is on left in LTR sidebar; flip to right in RTL */
[dir="rtl"] .brand-link {
    border-right: none !important;
    border-left: none !important;
}

/* Sidebar user panel image margin */
[dir="rtl"] .user-panel .image {
    padding-right: 0;
    padding-left: 0.8rem;
}

/* ── 5. Navbar ────────────────────────────────────────────────────── */
[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

/* Flip ml-auto everywhere … */
[dir="rtl"] .ml-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* … but restore it inside the navbar (direction:ltr there, needs normal LTR push-right) */
[dir="rtl"] .main-header .ml-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* User image in navbar */
[dir="rtl"] .user-menu .user-image {
    float: right;
    margin-right: 0;
    margin-left: 10px;
}

/* Sign-out button in user footer */
[dir="rtl"] .user-footer .float-right {
    float: left !important;
}

/* ── 6. Dropdowns ─────────────────────────────────────────────────── */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .dropdown-menu-right {
    right: auto !important;
    left: 0 !important;
}

/* ── 7. Bootstrap float / text utilities ─────────────────────────── */
[dir="rtl"] .float-right    { float: left !important; }
[dir="rtl"] .float-left     { float: right !important; }
[dir="rtl"] .float-sm-right { float: left !important; }
[dir="rtl"] .float-sm-left  { float: right !important; }

[dir="rtl"] .text-right { text-align: left !important; }
[dir="rtl"] .text-left  { text-align: right !important; }

/* ── 8. Bootstrap margin utilities ───────────────────────────────── */
[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .mr-auto { margin-right: 0 !important; margin-left: auto !important; }

[dir="rtl"] .ml-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
[dir="rtl"] .ml-2 { margin-left: 0 !important; margin-right: 0.5rem  !important; }
[dir="rtl"] .ml-3 { margin-left: 0 !important; margin-right: 1rem    !important; }

[dir="rtl"] .mr-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .mr-2 { margin-right: 0 !important; margin-left: 0.5rem  !important; }
[dir="rtl"] .mr-3 { margin-right: 0 !important; margin-left: 1rem    !important; }

/* ── 9. Input groups ──────────────────────────────────────────────── */
[dir="rtl"] .input-group-prepend {
    margin-right: 0;
    margin-left: -1px;
}

[dir="rtl"] .input-group-append {
    margin-left: 0;
    margin-right: -1px;
}

/* Flip border-radius so rounded end is on the correct side */
[dir="rtl"] .input-group > .form-control:not(:last-child),
[dir="rtl"] .input-group > .custom-select:not(:last-child) {
    border-radius: 0 0.25rem 0.25rem 0;
}

[dir="rtl"] .input-group > .form-control:not(:first-child),
[dir="rtl"] .input-group > .custom-select:not(:first-child) {
    border-radius: 0.25rem 0 0 0.25rem;
}

[dir="rtl"] .input-group-prepend .input-group-text,
[dir="rtl"] .input-group-prepend .btn {
    border-radius: 0 0.25rem 0.25rem 0;
}

[dir="rtl"] .input-group-append .input-group-text,
[dir="rtl"] .input-group-append .btn {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* ── 10. Cards ────────────────────────────────────────────────────── */
[dir="rtl"] .card-tools {
    float: left !important;
    margin-right: 0;
    margin-left: -0.625rem;
}

[dir="rtl"] .card-header { text-align: right; }

/* ── 11. Breadcrumb ───────────────────────────────────────────────── */
[dir="rtl"] .breadcrumb {
    direction: rtl;
    padding-right: 1rem;
    padding-left: 0;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item {
    padding-left: 0;
    padding-right: 0.5rem;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    padding-right: 0;
    padding-left: 0.5rem;
    float: right;
}

/* ── 12. Tables ───────────────────────────────────────────────────── */
[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* ── 13. Alerts / close button ────────────────────────────────────── */
[dir="rtl"] .close {
    float: left;
    margin-left: 0;
    margin-right: auto;
}

/* ── 14. Pagination ───────────────────────────────────────────────── */
[dir="rtl"] .pagination { direction: rtl; }

/* ── 15. Timeline ─────────────────────────────────────────────────── */
[dir="rtl"] .timeline > div > i {
    left: auto;
    right: 15px;
}

[dir="rtl"] .timeline > div > .timeline-item {
    margin-left: 0;
    margin-right: 60px;
}

[dir="rtl"] .timeline > div > .timeline-item > .time {
    float: left;
}

/* ── 16. Info-box: icon on right in RTL ───────────────────────────── */
[dir="rtl"] .info-box-icon {
    border-radius: 0 0.25rem 0.25rem 0;
}

[dir="rtl"] .info-box-content {
    text-align: right;
}

/* ── 17. Toastr notifications ─────────────────────────────────────── */
[dir="rtl"] #toast-container.toast-top-right    { right: auto; left: 12px; }
[dir="rtl"] #toast-container.toast-bottom-right { right: auto; left: 12px; }

/* ── 18. Forms ────────────────────────────────────────────────────── */
[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.25rem;
}

[dir="rtl"] .form-check-input {
    margin-left: 0;
    margin-right: -1.25rem;
}

/* ── 19. Landing page nav ─────────────────────────────────────────── */
[dir="rtl"] .landing-nav .nav-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .landing-nav .brand img {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .hero-section h1,
[dir="rtl"] .hero-section .lead {
    text-align: right;
}

[dir="rtl"] .hero-btns { justify-content: flex-start; }

/* Keep stat numbers LTR (digits read left-to-right) */
[dir="rtl"] .stat-number { direction: ltr; display: inline-block; }

/* ── 20. Login split card: swap panel order in RTL ────────────────── */
[dir="rtl"] .login-card     { flex-direction: row-reverse; }
[dir="rtl"] .login-topbar   { flex-direction: row-reverse; }
[dir="rtl"] .back-link i    { transform: scaleX(-1); display: inline-block; }

/* ── 21. Responsive ───────────────────────────────────────────────── */
/* AdminLTE clears LTR sidebar inset below ~992px, which leaves the fixed sidebar
   overlapping content. For RTL the bar is on the right — same rule made the main
   column full-width while the sidebar still showed, so it covered the header.
   Only clear inset below 768px when the sidebar is off-canvas (matches mobile hide). */
@media (max-width: 767.98px) {
    [dir="rtl"] .main-header,
    [dir="rtl"] .content-wrapper,
    [dir="rtl"] .main-footer {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* LTR hides the left sidebar with margin-left:-250px; mirror for fixed right bar */
    [dir="rtl"] .main-sidebar,
    [dir="rtl"] .main-sidebar::before {
        margin-left: 0 !important;
        margin-right: -250px !important;
    }

    [dir="rtl"] body.sidebar-open .main-sidebar,
    [dir="rtl"] body.sidebar-open .main-sidebar::before {
        margin-right: 0 !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-box, .register-box {
        width: 90%;
        margin: 10% auto;
    }

    .info-box       { margin-bottom: 1rem; }
    .client-status-card { margin-bottom: 1rem; }
}

/* ── Phase 6: global loading overlay ─────────────────────────────── */
.admin-global-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.admin-global-overlay.is-visible {
    display: flex;
    pointer-events: auto;
}

.admin-global-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.admin-global-overlay__box {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #fff;
    padding: 1.5rem;
    min-width: 220px;
}

.admin-global-overlay__text {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.admin-global-overlay__progress {
    margin-top: 1rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Phase 6: dark theme (content shell; sidebar stays AdminLTE dark) ─ */
[data-admin-theme="dark"] .content-wrapper {
    background: #1a1d21 !important;
    color: #e9ecef;
}

[data-admin-theme="dark"] .content-header h1,
[data-admin-theme="dark"] .breadcrumb-item,
[data-admin-theme="dark"] .breadcrumb-item a {
    color: #e9ecef;
}

[data-admin-theme="dark"] .content-header .breadcrumb-item.active {
    color: #adb5bd;
}

[data-admin-theme="dark"] .card {
    background: #25292e;
    color: #e9ecef;
    border-color: #343a40;
}

[data-admin-theme="dark"] .card-header {
    background: #2c3136;
    border-color: #343a40;
    color: #f8f9fa;
}

[data-admin-theme="dark"] .main-header.navbar-light {
    background: #25292e !important;
    border-color: #343a40 !important;
}

[data-admin-theme="dark"] .main-header .navbar-nav .nav-link {
    color: #e9ecef !important;
}

[data-admin-theme="dark"] .main-footer {
    background: #25292e;
    border-color: #343a40;
    color: #adb5bd;
}

[data-admin-theme="dark"] .table {
    color: #e9ecef;
}

[data-admin-theme="dark"] .table-bordered {
    border-color: #343a40;
}

[data-admin-theme="dark"] .modal-content {
    background: #25292e;
    color: #e9ecef;
    border-color: #343a40;
}

[data-admin-theme="dark"] .modal-header,
[data-admin-theme="dark"] .modal-footer {
    border-color: #343a40;
}

[data-admin-theme="dark"] .close {
    color: #fff;
    text-shadow: none;
    opacity: 0.8;
}

[data-admin-theme="dark"] .form-control {
    background: #1e2226;
    border-color: #495057;
    color: #e9ecef;
}

[data-admin-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

/* ── Phase 6: keyboard shortcuts modal ───────────────────────────── */
.admin-shortcuts-list kbd {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.85em;
    font-family: inherit;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    color: #212529;
}

[data-admin-theme="dark"] .admin-shortcuts-list kbd {
    background: #343a40;
    border-color: #495057;
    color: #f8f9fa;
}

/* ── Phase 6: mobile touch targets & safe area ───────────────────── */
@media (max-width: 767.98px) {
    .main-sidebar .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .main-header .nav-link,
    .main-header .btn.nav-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .layout-fixed .wrapper .main-header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}