:root {
    --navy: #14243a;
    --navy-light: #203b5d;
    --blue: #d9eaf7;
    --gold: #f4b183;
    --background: #f4f7fb;
    --white: #ffffff;
    --text: #1d2939;
    --muted: #667085;
    --border: #e5eaf0;
    --green: #16845b;
    --red: #c43d4b;
    --shadow: 0 8px 24px rgba(20, 36, 58, .07);
}

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

body {
    font-family: Arial, "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

button {
    cursor: pointer;
}

/* APP LAYOUT */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* SIDEBAR */

.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--navy);
    color: var(--white);
    padding: 25px 15px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px 30px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--gold);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    font-weight: 900;
}

.brand-info h2 {
    font-size: 18px;
    font-weight: 800;
}

.brand-info span {
    font-size: 11px;
    color: #b7c6d8;
    display: block;
    margin-top: 4px;
}

.sidebar-menu {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-label {
    color: #8da2b9;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 15px 12px 7px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    border: none;
    background: transparent;
    color: #d7e0ea;
    text-align: right;
    padding: 12px 14px;
    border-radius: 9px;
    font-size: 13px;
    transition: .2s;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: white;
}

.nav-item.active {
    background: var(--navy-light);
    color: white;
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px 10px 0;
    border-top: 1px solid rgba(255,255,255,.1);
    color: #a8b9cb;
    font-size: 11px;
}

.sidebar-footer small {
    display: block;
    margin-top: 5px;
    color: #8096ae;
}

/* MAIN CONTENT */

.main-content {
    flex: 1;
    min-width: 0;
    padding: 28px 34px 20px;
}

.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.header-subtitle {
    display: block;
    color: #8090a3;
    font-size: 10px;
    letter-spacing: 2px;
    font-weight: bold;
}

.header-title h1 {
    margin-top: 6px;
    font-size: 27px;
    color: var(--navy);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.current-date {
    color: var(--muted);
    font-size: 12px;
}

/* BUTTONS */

.btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    padding: 10px 15px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 700;
    transition: .2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary {
    background: var(--navy);
    border-color: var(--navy);
    color: white;
}

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

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

.btn-danger {
    color: var(--red);
    border-color: #f2c8cd;
}

.btn-small {
    padding: 6px 9px;
    font-size: 10px;
}

/* DASHBOARD */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 19px;
    box-shadow: var(--shadow);
}

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

.stat-number {
    font-size: 30px;
    font-weight: 800;
    color: var(--navy);
    margin-top: 10px;
}

.stat-sub {
    font-size: 10px;
    color: #8a97a7;
    margin-top: 5px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 19px;
    box-shadow: var(--shadow);
}

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

.panel-header h3 {
    font-size: 15px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.quick-tile {
    border: 1px solid var(--border);
    background: #fbfcfe;
    border-radius: 10px;
    padding: 15px;
    text-align: right;
    transition: .2s;
}

.quick-tile:hover {
    background: var(--blue);
    border-color: #b6d2e7;
}

.quick-tile strong {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
}

.quick-tile span {
    color: var(--muted);
    font-size: 10px;
}

/* LIST ROWS */

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: none;
}

.list-row strong {
    font-size: 12px;
}

.list-row small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    margin-top: 4px;
}

/* BADGES */

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 20px;
    background: #edf2f7;
    color: #475467;
    font-size: 10px;
    white-space: nowrap;
}

.badge-green {
    background: #e8f7ef;
    color: #067647;
}

.badge-red {
    background: #fff0f0;
    color: #b42318;
}

.badge-gold {
    background: #fff5e8;
    color: #9a5b00;
}

/* TABLES */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-input {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    min-width: 220px;
    background: white;
    outline: none;
}

.search-input:focus {
    border-color: var(--navy-light);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 750px;
}

thead {
    background: #f8fafc;
}

th {
    color: #667085;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

td {
    font-size: 12px;
    color: var(--text);
}

th,
td {
    text-align: right;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #fafcff;
}

tbody tr:last-child td {
    border-bottom: none;
}

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

/* EMPTY STATES */

.empty-state {
    padding: 40px 20px;
    text-align: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--muted);
    font-size: 13px;
}

.loading-screen {
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

/* MODALS */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10,22,38,.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 1000;
}

.modal {
    width: min(680px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

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

.modal-header h2 {
    font-size: 18px;
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 18px;
}

/* FORMS */

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    color: #475467;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    border: 1px solid #d9e0e8;
    border-radius: 8px;
    padding: 11px;
    background: white;
    font-size: 12px;
    color: var(--text);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--navy-light);
}

.form-group textarea {
    min-height: 85px;
    resize: vertical;
}

/* DETAILS */

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

.detail-item {
    padding: 12px;
    border-radius: 9px;
    background: #f8fafc;
    overflow-wrap: anywhere;
}

.detail-item small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    margin-bottom: 6px;
}

.detail-item strong {
    font-size: 12px;
}

/* SETTINGS */

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

.settings-card {
    padding: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.settings-card h3 {
    font-size: 15px;
    margin-bottom: 10px;
}

.settings-card p {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.8;
}

/* TOAST */

.toast {
    position: fixed;
    bottom: 22px;
    left: 22px;
    background: var(--navy);
    color: white;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: .2s;
    z-index: 2000;
    pointer-events: none;
    font-size: 12px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* FOOTER */

.app-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 25px 10px;
    color: #9aa5b1;
    font-size: 10px;
}

/* RESPONSIVE */

@media (max-width: 1050px) {

    .sidebar {
        width: 220px;
        min-width: 220px;
    }

    .main-content {
        padding: 22px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}

@media (max-width: 750px) {

    .app-container {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        min-height: auto;
        padding: 13px;
    }

    .brand {
        padding: 0 5px 12px;
    }

    .sidebar-menu {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        margin-top: 12px;
        gap: 5px;
    }

    .menu-label {
        display: none;
    }

    .nav-item {
        width: auto;
        white-space: nowrap;
        flex-shrink: 0;
        padding: 10px 12px;
        font-size: 11px;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        padding: 18px 13px;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 480px) {

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-card {
        padding: 13px;
    }

    .stat-number {
        font-size: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: auto;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .search-input {
        width: 100%;
        min-width: 0;
    }

    .app-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

}

/* =========================================================
   WISO IT - Arabic / English Layout Support
========================================================= */

/* Direction support */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

/* Main layout */
html[dir="rtl"] .app-container {
    direction: rtl;
}

html[dir="ltr"] .app-container {
    direction: ltr;
}

/* Sidebar */
.nav-item {
    text-align: start;
}

html[dir="rtl"] .nav-item {
    text-align: right;
}

html[dir="ltr"] .nav-item {
    text-align: left;
}

/* Header */
.header-title {
    text-align: start;
}

.header-actions {
    flex-wrap: wrap;
}

.current-date {
    text-align: start;
}

/* Dashboard */
.quick-tile {
    text-align: start;
}

.list-row {
    text-align: start;
}

/* Tables */
th,
td {
    text-align: start;
}

.actions {
    justify-content: flex-start;
}

/* Forms */
.form-group label {
    text-align: start;
}

.form-group input,
.form-group select,
.form-group textarea {
    text-align: start;
}

html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="number"] {
    direction: rtl;
}

html[dir="ltr"] input[type="date"],
html[dir="ltr"] input[type="number"] {
    direction: ltr;
}

/* Details */
.detail-item {
    text-align: start;
}

/* Modal */
.modal-header {
    text-align: start;
}

.modal-footer {
    flex-wrap: wrap;
}

/* Toast */
.toast {
    left: auto;
    right: auto;
    inset-inline-start: 22px;
    text-align: start;
}

/* Footer */
.app-footer {
    flex-wrap: wrap;
}

/* Language button */
#languageToggle {
    min-width: 85px;
    font-weight: 700;
}

/* Better Arabic typography */
html[lang="ar"] body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

html[lang="ar"] button,
html[lang="ar"] input,
html[lang="ar"] select,
html[lang="ar"] textarea {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

/* Responsive improvements */
@media (max-width: 750px) {
    .header-actions {
        flex-wrap: wrap;
    }

    .header-actions > * {
        max-width: 100%;
    }

    .toast {
        inset-inline-start: 12px;
        inset-inline-end: 12px;
        bottom: 12px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 8px;
    }

    .header-actions .btn {
        padding: 9px 11px;
    }

    .modal-footer {
        justify-content: stretch;
    }

    .modal-footer .btn {
        flex: 1;
    }
}
