/* =========================================
   1. GLOBAL & LAYOUT
   ========================================= */
.crm-calc-wrapper, .crm-calc-wrapper-front {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #444;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-sizing: border-box;
}

/* Modern Tabs Styling */
.nav-tab-wrapper {
    border-bottom: 1px solid #e0e0e0 !important;
    margin-bottom: 20px !important;
    padding-bottom: 0 !important;
}

.nav-tab {
    border: none !important;
    background: transparent !important;
    color: #7f8c8d !important;
    font-weight: 600 !important;
    padding: 12px 20px !important;
    font-size: 15px !important;
    transition: all 0.2s;
    margin-right: 5px !important;
}

.nav-tab:hover {
    color: #3498db !important;
    background: rgba(52, 152, 219, 0.05) !important;
}

.nav-tab-active {
    color: #2c3e50 !important;
    border-bottom: 3px solid #3498db !important;
    background: #fff !important;
}

/* =========================================
   2. MODERN DASHBOARD (Statistiques)
   ========================================= */
.crm-dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
}

.crm-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}
.crm-dashboard-header h2 { margin: 0; font-size: 24px; color: #23282d; font-weight: 700; }
.crm-dashboard-header p { margin: 5px 0 0; color: #72777c; font-size: 14px; }

.button-link-delete { color: #a00 !important; text-decoration: none; display: flex; align-items: center; gap: 5px; background: none !important; border: none !important; cursor: pointer; }
.button-link-delete:hover { color: #dc3232 !important; text-decoration: underline !important; }

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

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 25px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }

/* Gradients & Themes */
.card-gradient-blue { background: linear-gradient(135deg, #fff 0%, #f0f7ff 100%); border-left: 4px solid #3498db; }
.card-gradient-green { background: linear-gradient(135deg, #fff 0%, #f0fff4 100%); border-left: 4px solid #2ecc71; }
.card-gradient-purple { background: linear-gradient(135deg, #fff 0%, #f8f0ff 100%); border-left: 4px solid #9b59b6; }

.stat-content { position: relative; z-index: 2; }
.stat-label { display: block; font-size: 13px; color: #888; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 5px; }
.stat-value { margin: 0; font-size: 32px; font-weight: 800; color: #2c3e50; line-height: 1.2; }
.stat-desc { display: block; font-size: 12px; color: #aaa; margin-top: 5px; }

.stat-icon-bg {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.1;
    z-index: 1;
}
.stat-icon-bg .dashicons { font-size: 60px; width: 60px; height: 60px; color: #000; }

/* Dashboard Panels */
.crm-dashboard-body { display: flex; gap: 25px; flex-wrap: wrap; }
.dashboard-panel { background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); border: 1px solid #e5e5e5; overflow: hidden; }
.chart-panel { flex: 1; min-width: 350px; }
.logs-panel { flex: 1.5; min-width: 400px; }

.panel-header { padding: 15px 20px; background: #fff; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; }
.panel-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: #333; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 20px; }
.panel-body.p-0 { padding: 0; }

.chart-wrapper-canvas { position: relative; height: 300px; width: 100%; display: flex; align-items: center; justify-content: center; }

/* Logs Table */
.crm-logs-table { width: 100%; border-collapse: collapse; }
.crm-logs-table th { background: #f9f9f9; padding: 12px 15px; text-align: left; font-size: 12px; font-weight: 600; color: #666; text-transform: uppercase; border-bottom: 1px solid #eee; }
.crm-logs-table td { padding: 12px 15px; border-bottom: 1px solid #f5f5f5; color: #444; font-size: 13px; vertical-align: middle; }
.crm-logs-table tr:hover { background: #fcfcfc; }

.col-date small { display: block; color: #999; font-size: 11px; margin-top: 2px; }
.metric-badge { background: #f0f0f1; padding: 3px 8px; border-radius: 4px; font-weight: 600; color: #555; font-size: 12px; }
.gmat-score { font-weight: 800; font-size: 14px; }
.score-high { color: #27ae60; }
.score-mid { color: #f39c12; }
.score-low { color: #e74c3c; }

/* Pagination */
.panel-footer { padding: 10px 20px; border-top: 1px solid #f0f0f0; background: #fff; text-align: center; }
.pagination-simple .page-numbers { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border: 1px solid #e5e5e5; border-radius: 4px; margin: 0 2px; text-decoration: none; color: #555; font-weight: 600; transition: all 0.2s; }
.pagination-simple .page-numbers:hover { background: #f0f0f0; }
.pagination-simple .page-numbers.current { background: #3498db; color: #fff; border-color: #3498db; }

/* =========================================
   3. MATRIX EDITOR (Excel Style)
   ========================================= */
.matrix-editor-container {
    background: #fff;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border-radius: 4px;
    overflow: hidden;
}

.matrix-actions-bar {
    padding: 15px;
    background: #f0f6fc;
    border-bottom: 1px solid #e1e4e8;
}

.table-responsive-wrapper {
    max-height: 65vh; /* ارتفاع مناسب للعين */
    overflow: auto;
    position: relative;
    background: #fcfcfc;
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
}

.matrix-table th, .matrix-table td {
    padding: 0;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    width: 60px; /* عرض ثابت */
    min-width: 60px;
    height: 38px;
    text-align: center;
    vertical-align: middle;
    box-sizing: border-box;
}

/* Excel-like Inputs */
.matrix-table input.tiny-input {
    width: 100%;
    height: 100%;
    border: none !important;
    background: transparent !important;
    text-align: center;
    font-size: 14px;
    font-family: 'Segoe UI', Roboto, sans-serif;
    color: #333;
    font-weight: 500;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none !important;
    transition: all 0.1s ease;
    -moz-appearance: textfield;
}

.matrix-table input.tiny-input:focus {
    background: #fff !important;
    box-shadow: inset 0 0 0 2px #2271b1 !important;
    color: #2271b1 !important;
    font-weight: bold;
    z-index: 5;
    position: relative;
}

/* Hide Spinners */
.matrix-table input.tiny-input::-webkit-outer-spin-button,
.matrix-table input.tiny-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Sticky Headers */
.matrix-table thead th {
    background: #f0f0f1;
    color: #1d2327;
    font-weight: 600;
    font-size: 13px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 0 #dcdcde;
}

/* Sticky First Column (Verbal) - Updated for Dark Text */
.matrix-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 30;
    background: #e6e7e8 !important; /* خلفية رمادية فاتحة */
    color: #000 !important;          /* لون النص أسود قاتم */
    font-weight: 800;
    border-right: 2px solid #ccc;
    vertical-align: middle;
    line-height: 34px; /* لضمان توسط الرقم عمودياً */
}

/* Top Left Corner */
.matrix-table .sticky-corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 40;
    background: #2c3e50 !important;
    color: #2271b1 !important;
    border-right: 2px solid #1a252f;
    border-bottom: 1px solid #1a252f;
}

/* Hover Effects */
.hover-row td { background-color: #f0f6fc !important; }
.hover-col { background-color: #f0f6fc !important; }
.hover-col-header { background-color: #e5f1fb !important; color: #2271b1 !important; }

/* Sticky Footer */
.sticky-footer-actions {
    position: sticky;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    padding: 15px;
    border-top: 1px solid #ddd;
    text-align: right;
    z-index: 50;
}

/* =========================================
   4. FOCUS EDITOR (Admin)
   ========================================= */
.focus-editor-container { max-width: 1000px; margin: 0 auto; }
.focus-table th { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.focus-row:hover { background-color: #f9fcff; }

.score-badge {
    display: inline-block;
    background: #2c3e50;
    color: #fff;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

.focus-table input[type="number"], .focus-table input[type="text"] {
    border: 1px solid #ddd;
    box-shadow: none;
    transition: border-color 0.2s;
}
.focus-table input:focus { border-color: #3498db; box-shadow: 0 0 0 1px #3498db; }

/* Dynamic Input Rows */
.multi-input-wrapper { display: flex; flex-direction: column; gap: 5px; }
.input-row { display: flex; align-items: center; gap: 5px; }
.remove-sub-row {
    background: #e74c3c; color: #0f172a; border: none; border-radius: 50%;
    width: 20px; height: 20px; line-height: 20px; cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.remove-sub-row:hover { background: #c0392b; }

.delete-focus-row {
    width: 36px; height: 36px; border-radius: 50%;
    padding: 0; display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.delete-focus-row:hover { background: #c0392b !important; color: #fff !important; transform: scale(1.1); }
.delete-focus-row .dashicons { font-size: 20px; width: 20px; height: 20px; }

/* =========================================
   5. RULES EDITOR
   ========================================= */
#rules_wrapper { background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); }
.rule-item {
    background: #fdfdfd; border: 1px solid #e1e1e1; border-left: 4px solid #3498db;
    border-radius: 4px; padding: 20px; margin-bottom: 15px;
}
.rule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px dashed #eee; }
.rule-conditions, .rule-message, .rule-links-wrapper { margin-bottom: 15px; }
.rule-item label { display: block; font-weight: 600; margin-bottom: 5px; color: #555; }
.small-input { width: 80px !important; text-align: center; }

/* Link Rows */
.link-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.link-row input { flex: 1; }

/* =========================================
   6. FRONTEND STYLES
   ========================================= */
.crm-calc-wrapper-front { max-width: 600px; margin: 40px auto; font-family: 'Segoe UI', Roboto, sans-serif; }
.crm-calc-box { background: #fff; padding: 40px; border-radius: 20px; box-shadow: 0 15px 50px rgba(0,0,0,0.08); border: 1px solid #f0f0f0; }

/* Inputs */
.input-group { margin-bottom: 25px; }
.input-group label { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 700; color: #2c3e50; font-size: 15px; }
.label-badge { padding: 4px 10px; border-radius: 20px; color: #fff; font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }
.label-badge.verbal { background: #27ae60; box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3); }
.label-badge.quant { background: #2980b9; box-shadow: 0 2px 5px rgba(41, 128, 185, 0.3); }

.range-wrap { display: flex; align-items: center; gap: 15px; background: #f9f9f9; padding: 8px 15px; border-radius: 12px; border: 1px solid #eee; }
.crm-range { flex-grow: 1; cursor: pointer; height: 6px; background: #e0e0e0; border-radius: 5px; -webkit-appearance: none; }
.crm-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; background: #34495e; border-radius: 50%; cursor: grab; border: 3px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.crm-number { width: 60px; border:none; background: transparent; text-align: center; font-weight: 800; font-size: 18px; color: #2c3e50; padding: 0; }

.button-primary-front { width: 100%; padding: 18px; background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 800; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 8px 20px rgba(52, 152, 219, 0.25); margin-top: 10px; }
.button-primary-front:hover { transform: translateY(-3px); box-shadow: 0 12px 25px rgba(52, 152, 219, 0.35); }

/* Results */
.calc-result-container { margin-top: 40px; }
.result-card { border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.06); border: 1px solid #e1e8ed; }

/* Focus Hero Section */
.focus-result-wrapper { background: linear-gradient(135deg, #ffffff 0%, #f4f8fb 100%); padding: 30px; text-align: center; position: relative; border-bottom: 1px solid #eee; }
.focus-ribbon { position: absolute; top: 15px; right: 15px; background: #e74c3c; color: #fff; font-size: 10px; font-weight: 800; padding: 4px 10px; border-radius: 20px; letter-spacing: 0.5px; box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3); }

.focus-header { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 20px; }
.focus-icon { font-size: 20px; }
.focus-title { font-size: 16px; font-weight: 800; color: #34495e; text-transform: uppercase; letter-spacing: 1px; }

.focus-main-score { margin: 20px 0; }
.focus-label { display: block; font-size: 14px; font-weight: 600; color: #7f8c8d; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* Pill Shape Score */
.score-circle {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 140px;
    width: auto;
    padding: 15px 40px;
    background: #fff;
    border-radius: 60px;
    margin: 0 auto;
    box-shadow: 0 0 0 6px rgba(52, 152, 219, 0.08), 0 8px 25px rgba(52, 152, 219, 0.15);
    border: 3px solid #3498db;
}
#focus_score_display { font-size: 46px; font-weight: 900; color: #2c3e50; letter-spacing: -1px; white-space: nowrap; line-height: 1; }

.focus-footer-stats { margin-top: 25px; display: flex; justify-content: center; gap: 30px; }
.focus-stat { display: flex; flex-direction: column; align-items: center; }
.stat-lbl { font-size: 11px; font-weight: 700; color: #95a5a6; text-transform: uppercase; margin-bottom: 3px; }
.stat-val { font-size: 18px; font-weight: 800; color: #27ae60; }
.focus-note { font-size: 11px; color: #bdc3c7; margin-top: 20px; margin-bottom: 0; font-style: italic; }

/* Classic Section */
.classic-score-section { padding: 20px; text-align: center; background: #fff; border-top: 1px dashed #e0e0e0; }
.result-label { display: block; font-size: 11px; color: #95a5a6; letter-spacing: 1px; font-weight: 700; margin-bottom: 5px; text-transform: uppercase; }
.score-display-small span { font-size: 32px; font-weight: 800; color: #7f8c8d; }

/* Suggestions */
.suggestion-box { padding: 25px; background: #fdfdfd; border-top: 1px solid #f0f0f0; text-align: center; }

/* Autocomplete UI */
.ui-autocomplete { background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto; overflow-x: hidden; z-index: 9999; padding: 0; }
.ui-menu-item { list-style: none; padding: 0; margin: 0; }
.ui-menu-item .ui-menu-item-wrapper { padding: 8px 12px; font-size: 13px; color: #444; cursor: pointer; border-bottom: 1px solid #f5f5f5; transition: background 0.1s; }
.ui-menu-item .ui-menu-item-wrapper:hover, .ui-menu-item .ui-menu-item-wrapper.ui-state-active { background: #eef7fc; color: #2980b9; border-left: 3px solid #3498db; }