/* CRM Anglor Styles - مطابق للتصميم الأصلي */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

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

:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-rgb: 102, 126, 234;
    --secondary-color: #4facfe;
    --secondary-dark: #00f2fe;
    --success-color: #10b981;
    --success-rgb: 16, 185, 129;
    --warning-color: #f59e0b;
    --warning-rgb: 245, 158, 11;
    --error-color: #ef4444;
    --error-rgb: 239, 68, 68;
    --info-color: #3b82f6;
    --info-rgb: 59, 130, 246;
    --ai-color: #10b981;
    --ai-rgb: 16, 185, 129;
    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --background-primary: #ffffff;
    --background-secondary: #f8fafc;
    --background-light: #f1f5f9;
    --sidebar-width: 280px; /* unified sidebar width */
    --border-color: #e5e7eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--background-light);
    color: var(--text-primary);
    margin: 0; /* Reset default browser margin to remove outer gaps */
    line-height: 1.6;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.app-container {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    inline-size: var(--sidebar-width);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0;
    block-size: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0; /* left in LTR, right in RTL */
    display: flex;
    flex-direction: column;
    z-index: 1000;
    will-change: transform;
    box-shadow: 0 0 0 rgba(0,0,0,0.0); /* neutral; page header has its own shadow */
    transition: transform 0.3s ease;
}

/* Off-canvas positions (overlay) */
html[dir="ltr"] .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
html[dir="rtl"] .sidebar { transform: translateX(var(--sidebar-width)); }
/* Open state */
.sidebar.open { transform: translateX(0) !important; }

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 8px;
    white-space: nowrap;
}

.logo .material-icons {
    font-size: 28px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.logo-subtitle {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 600;
    margin-top: 4px;
    line-height: 1.3;
}

.nav-menu {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    padding: 0 20px 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    font-weight: 700;
    margin: 1px 8px;
    border-radius: 8px;
    white-space: nowrap;
    font-size: 14px;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 4px 4px 0;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-item:hover::before {
    width: 4px;
    height: 24px;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-item.active::before {
    width: 4px;
    height: 32px;
    background: white;
}

.nav-item .material-icons {
    font-size: 20px;
    opacity: 0.9;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.nav-item:hover .material-icons,
.nav-item.active .material-icons {
    opacity: 1;
    transform: scale(1.1);
}

/* Main Content (logical, auto-respects RTL/LTR) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0 !important; /* overlay: لا مساحة محجوزة للـ sidebar */
    transition: margin 0.3s ease;
}

.header {
    background: white;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

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

.menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.menu-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
}

.menu-toggle:active {
    background: rgba(102, 126, 234, 0.2);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--background-secondary);
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

/* Content Area */
.content {
    /* تقليل التباعد الداخلي حتى تقترب الصفحة من القوائم */
    padding: 12px 16px;
    padding-inline-start: 0 !important; /* side next to sidebar */
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
    min-height: calc(100vh - 80px);
}

/* Page Header */
.page-header {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    position: relative;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 16px 16px 0 0;
}

.page-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
}

.page-header p {
    margin: 8px 0 0 0;
    color: var(--text-secondary);
    font-size: 16px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    min-height: 44px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn .material-icons {
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

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

.btn-secondary {
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-error {
    background: var(--error-color);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 28px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.stat-card.success {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: white;
}

.stat-card.warning {
    background: linear-gradient(135deg, #fa709a, #fee140);
    color: white;
}

.stat-card.info {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: var(--text-primary);
}

.stat-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    opacity: 0.9;
}

.stat-icon {
    font-size: 48px;
    opacity: 0.7;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background-secondary);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-title .material-icons {
    color: var(--primary-color);
}

.card-content {
    padding: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 16px 0;
}

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

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

.table th {
    background: var(--background-secondary);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    color: var(--text-primary);
    font-size: 14px;
}

.table tr:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

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

/* Badges */
.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

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

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

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

.badge.info {
    background: #dbeafe;
    color: #1e40af;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Sidebar للجوال */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
        z-index: 1001 !important;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3) !important;
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }

    .sidebar.collapsed {
        transform: translateX(100%) !important;
    }

    /* Main Content */
    .main-content {
        margin-right: 0;
        width: 100%;
    }

    /* Menu Toggle - ظاهر دائماً */
    .menu-toggle {
        display: flex !important;
        width: 44px !important;
        height: 44px !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent;
        border-radius: 8px;
        transition: background 0.2s;
    }

    .menu-toggle:hover,
    .menu-toggle:active {
        background: rgba(102, 126, 234, 0.1);
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Page Header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
        margin-bottom: 20px;
    }

    .page-header h1 {
        font-size: 22px;
    }

    /* Page Actions */
    .page-actions {
        width: 100%;
        justify-content: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .page-actions .btn {
        width: 100%;
    }

    /* Content */
    .content {
        padding: 16px;
    }

    /* Cards */
    .card {
        margin-bottom: 16px;
    }

    .card-header {
        padding: 16px;
    }

    .card-content {
        padding: 16px;
    }

    /* Buttons */
    .btn {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 15px;
    }

    /* Header */
    .header {
        padding: 12px 16px;
    }

    .header-right .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}


/* Inline validation and hints (Registration UX) */
.validation-message{color:#dc2626;font-size:12px;margin-top:6px}
.form-hint{color:var(--text-secondary);font-size:12px}
.form-input:focus{outline:2px solid var(--primary-color);outline-offset:2px;border-color:var(--primary-color)}


/* Auth pages responsiveness */
.auth-container{max-width:680px;margin-inline:auto}
@media (max-width:768px){
  .auth-container{padding:16px}
  .auth-container .row.auth-grid{display:block !important}
  .auth-container .d-flex.gap-2{flex-direction:column;gap:10px}
  .auth-container .btn{width:100%}
  .form-input{min-height:48px}
}


/* Visual polish for auth and forms */
.auth-card{transition:box-shadow .25s ease, transform .2s ease}
.auth-card:hover{box-shadow:0 16px 40px rgba(0,0,0,.12);transform:translateY(-2px)}
.auth-header{position:relative}
.auth-steps .step{transition:transform .2s ease, box-shadow .2s ease}
.auth-steps .step.current{box-shadow:0 2px 6px rgba(0,0,0,.15)}
.auth-steps .step:hover{transform:translateY(-1px)}
.form-label{font-weight:600}
.form-input{transition:border-color .2s ease, box-shadow .2s ease}
.alert{border-radius:10px}
/* Reduce motion for users preferring less animation */
@media (prefers-reduced-motion: reduce){
  *{animation:none!important;transition:none!important}
}

/* AI Assistant Button Styles */
.ai-assistant-btn {
    position: relative;
    transition: all 0.3s ease;
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
}

.ai-assistant-btn .material-icons {
    animation: pulse-ai 2s ease-in-out infinite;
}

@keyframes pulse-ai {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.ai-assistant-btn:hover .material-icons {
    animation: none;
    transform: scale(1.1);
}

/* Language Switcher Dropdown in Header */
.language-dropdown-header {
    min-width: 140px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    background: white;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
}

.language-dropdown-header:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.language-dropdown-header:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.language-switcher {
    display: flex;
    align-items: center;
}
