/**
 * EnableNext Compliance Platform
 * Custom Application Styles
 */

/* ==========================================================================
   Font Definitions
   ========================================================================== */

/* Inter - Primary font for LTR languages */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/assets/fonts/inter/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/assets/fonts/inter/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Noto Sans Arabic - For RTL Arabic content */
@font-face {
    font-family: 'Noto Sans Arabic';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/assets/fonts/noto-sans-arabic/noto-sans-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-info: #0891b2;
    --sidebar-width: 256px;
    --sidebar-collapsed-width: 64px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
}

html {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    scroll-behavior: smooth;
}

/* RTL Support */
html[dir="rtl"] {
    font-family: 'Noto Sans Arabic', 'Inter', system-ui, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

/* ==========================================================================
   Layout Structure
   ========================================================================== */

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

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: #111827;
    color: #f9fafb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
    z-index: 40;
}

html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--header-height);
}

.sidebar-logo {
    height: 32px;
    width: auto;
}

.sidebar-brand {
    font-weight: 600;
    font-size: 1.125rem;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-group {
    margin-bottom: 0.5rem;
}

/* Collapsible navigation group toggle button */
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.nav-group-toggle:hover {
    color: #d1d5db;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-group-toggle .nav-group-label {
    padding: 0;
}

.nav-group-chevron {
    font-size: 0.625rem;
    transition: transform 0.2s ease;
}

.nav-group-toggle.expanded .nav-group-chevron {
    transform: rotate(90deg);
}

html[dir="rtl"] .nav-group-toggle.expanded .nav-group-chevron {
    transform: rotate(-90deg);
}

/* Collapsible group items container */
.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}

.nav-group-items.expanded {
    max-height: 500px;
    transition: max-height 0.35s ease-in;
}

/* Admin section styling */
.nav-group-admin {
    margin-top: auto;
    border-top: 1px solid #374151;
    padding-top: 0.5rem;
}

/* Legacy nav-group-label for backwards compatibility */
.nav-group-label {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-group-toggle {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    color: #d1d5db;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    gap: 0.75rem;
    border-left: 3px solid transparent;
}

html[dir="rtl"] .nav-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background-color: #1f2937;
    color: #f9fafb;
}

.nav-item.active {
    background-color: #1f2937;
    color: #60a5fa;
    border-left-color: #3b82f6;
}

html[dir="rtl"] .nav-item.active {
    border-left-color: transparent;
    border-right-color: #3b82f6;
}

.nav-item i {
    font-size: 1.125rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-item span {
    white-space: nowrap;
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.nav-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #3b82f6;
    color: white;
    border-radius: 9999px;
}

html[dir="rtl"] .nav-badge {
    margin-left: 0;
    margin-right: auto;
}

.sidebar.collapsed .nav-badge {
    display: none;
}

/* Sidebar toggle */
.sidebar-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem;
    padding: 0.5rem;
    background: #374151;
    border: none;
    border-radius: 0.375rem;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.15s;
}

.sidebar-toggle:hover {
    color: #f9fafb;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
}

html[dir="rtl"] .main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

html[dir="rtl"] .sidebar.collapsed ~ .main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-collapsed-width);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 30;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-org {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Header buttons */
.header-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    color: #6b7280;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.header-btn:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.header-btn i {
    font-size: 1.25rem;
}

.header-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.625rem;
    font-weight: 600;
    background-color: #dc2626;
    color: white;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide mobile menu toggle on desktop */
.header-btn[data-mobile-menu] {
    display: none;
}

@media (max-width: 1024px) {
    .header-btn[data-mobile-menu] {
        display: flex;
    }
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.user-menu:hover {
    background-color: #f9fafb;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: #3b82f6;
    color: white;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* Main content */
.main-content {
    padding: 1.5rem;
    min-height: calc(100vh - var(--header-height));
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: #6b7280;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #3b82f6;
}

.breadcrumb-separator {
    color: #d1d5db;
}

.breadcrumb-current {
    color: #1f2937;
    font-weight: 500;
}

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

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

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

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

html[dir="rtl"] .toast-container {
    right: auto;
    left: 1rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    border-left: 4px solid;
    pointer-events: auto;
    animation: toast-slide-in 0.3s ease;
    max-width: 400px;
}

html[dir="rtl"] .toast {
    border-left: none;
    border-right: 4px solid;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

html[dir="rtl"] @keyframes toast-slide-in {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-success {
    border-color: var(--color-success);
}

.toast.toast-success i {
    color: var(--color-success);
}

.toast.toast-error {
    border-color: var(--color-danger);
}

.toast.toast-error i {
    color: var(--color-danger);
}

.toast.toast-warning {
    border-color: var(--color-warning);
}

.toast.toast-warning i {
    color: var(--color-warning);
}

.toast.toast-info {
    border-color: var(--color-info);
}

.toast.toast-info i {
    color: var(--color-info);
}

.toast i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: #374151;
}

.toast-close {
    padding: 0.25rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: color 0.15s;
}

.toast-close:hover {
    color: #4b5563;
}

/* ==========================================================================
   Dropdown Menus
   ========================================================================== */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 200px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
    z-index: 50;
}

html[dir="rtl"] .dropdown-menu {
    right: auto;
    left: 0;
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.dropdown-header-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: #111827;
}

.dropdown-header-subtitle {
    font-size: 0.75rem;
    color: #6b7280;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background-color: #f9fafb;
}

.dropdown-item i {
    width: 1.25rem;
    text-align: center;
    color: #6b7280;
}

.dropdown-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.25rem 0;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background-color: #ffffff;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
    border-radius: 0 0 0.5rem 0.5rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-dark);
}

.btn-secondary {
    background-color: #ffffff;
    border-color: #d1d5db;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #f9fafb;
}

.btn-success {
    background-color: var(--color-success);
    color: #ffffff;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.form-label.required::after {
    content: ' *';
    color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: #ffffff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--color-danger);
}

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

.form-help {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background-color: #f9fafb;
}

.table tbody tr:hover {
    background-color: #f9fafb;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #e0f2fe;
    color: #075985;
}

.badge-neutral {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* ==========================================================================
   Help Modal
   ========================================================================== */

.help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    color: #9ca3af;
    background: #f3f4f6;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.help-trigger:hover {
    color: #3b82f6;
    background-color: #dbeafe;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.modal-close {
    padding: 0.25rem;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 0.25rem;
}

.modal-close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 130px);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-muted {
    color: #6b7280;
}

.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

.text-warning {
    color: var(--color-warning);
}

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

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.hidden {
    display: none !important;
}

/* ==========================================================================
   Toggle Switches
   ========================================================================== */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    border-radius: 24px;
    transition: background-color 0.2s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

html[dir="rtl"] .toggle-slider:before {
    left: auto;
    right: 2px;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

html[dir="rtl"] .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(-20px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

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

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

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

    .main-wrapper {
        margin-left: 0 !important;
    }

    html[dir="rtl"] .main-wrapper {
        margin-right: 0 !important;
    }
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }
}
