/**
 * Snippets Module - Admin Styles
 *
 * Handles styling for the Repeater Fields in settings, TinyMCE integration,
 * AJAX Search Dropdown, and Z-Index  for modal interactions.
 *
 * @package    Kabook_Editor_Tools
 * @subpackage Kabook_Editor_Tools/modules/snippets/assets
 * @author     Kabook
 * @license    GPL-2.0+
 */

/* ==========================================================================
   1. TinyMCE Button Styling
   ========================================================================== */

/* Icon Color (Kabook Blue) */
.mce-kabook-blue-trigger .mce-ico {
	color: #005bea !important;
}

/* Text Styling (Standard Dark) */
.mce-kabook-blue-trigger .mce-txt {
	color: #333 !important;
	font-weight: normal !important;
}

/* Hover Effects */
.mce-kabook-blue-trigger:hover {
	background-color: #e3f2fd !important;
	border-color: #b3e5fc !important;
}

.mce-kabook-blue-trigger:hover .mce-ico {
	color: #002a6b !important;
}

.mce-kabook-blue-trigger:hover .mce-txt {
	color: #000 !important;
}

/* ==========================================================================
   2. AJAX Search Dropdown (Z-Index )
   ========================================================================== */

ul.ui-autocomplete {
	z-index: 100105 !important; /* Must be higher than TinyMCE Modal */
	background: #fff;
	border: 1px solid #ddd;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
	max-height: 200px;
	overflow-y: auto;
	overflow-x: hidden;
}

ul.ui-autocomplete li.ui-menu-item {
	padding: 8px 10px;
	border-bottom: 1px solid #f0f0f0;
	cursor: pointer;
	font-size: 13px;
}

ul.ui-autocomplete li.ui-menu-item:hover {
	background: #f0f7ff;
	color: #005bea;
}

.kabook-loading {
	background: url('images/spinner.gif') no-repeat right 10px center !important;
}

/* ==========================================================================
   3. Modal Header Harmony
   ========================================================================== */

div.mce-window[aria-label*='Search'] .mce-window-head,
div.mce-window[aria-label*='Snippet'] .mce-window-head {
	background: linear-gradient(90deg, #005bea 0%, #00c6fb 100%) !important;
	border-bottom: none !important;
}

div.mce-window[aria-label*='Search'] .mce-title,
div.mce-window[aria-label*='Snippet'] .mce-title {
	color: #fff !important;
	font-weight: 600 !important;
	letter-spacing: 0.5px;
}

div.mce-window[aria-label*='Search'] .mce-close,
div.mce-window[aria-label*='Snippet'] .mce-close {
	color: #fff !important;
}

/* ==========================================================================
   4. Settings Page UI
   ========================================================================== */

/* Guide Box */
.kabook-guide-box {
	background: #fff;
	border: 1px solid #e5e5e5;
	border-top: 3px solid #005bea;
	border-radius: 4px;
	padding: 20px;
	margin-bottom: 30px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.k-guide-title {
	margin-top: 0;
	color: #005bea;
	font-size: 16px;
	display: flex;
	align-items: center;
	gap: 5px;
}

.kabook-vars-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 15px;
}

.kabook-vars-table th {
	text-align: left;
	background: #f8f9fa;
	padding: 10px;
	border-bottom: 2px solid #e9ecef;
	color: #495057;
	font-size: 13px;
}

.kabook-vars-table td {
	padding: 10px;
	border-bottom: 1px solid #e9ecef;
	font-size: 13px;
	color: #333;
}

.kabook-vars-table code {
	background: #e3f2fd;
	color: #005bea;
	padding: 3px 6px;
	border-radius: 3px;
}

/* Toggles Grid */
.kabook-toggles-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 15px;
	margin-bottom: 30px;
}

.k-toggle-item {
	background: #fff;
	padding: 15px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.kabook-switch {
	position: relative;
	width: 40px;
	height: 22px;
}

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

.kabook-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #cbd5e1;
	transition: .3s;
	border-radius: 34px;
}

.kabook-slider:before {
	position: absolute;
	content: "";
	height: 16px;
	width: 16px;
	left: 3px;
	bottom: 3px;
	background-color: white;
	transition: .3s;
	border-radius: 50%;
}

.kabook-switch input:checked + .kabook-slider {
	background-color: #005bea;
}

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

/* Repeater Fields */
.kabook-repeater-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
	border-top: 1px solid #e2e8f0;
	padding-top: 25px;
}

.snippet-row {
	background: #fff;
	border: 1px solid #e2e8f0;
	padding: 15px;
	margin-bottom: 10px;
	border-radius: 6px;
	display: flex;
	gap: 15px;
	align-items: flex-end;
	flex-wrap: wrap;
}

.k-input-group {
	flex: 1;
	min-width: 180px;
}

.k-code-group {
	flex: 2;
	min-width: 250px;
}

.k-input-group label {
	display: block;
	margin-bottom: 6px;
	font-weight: 500;
	font-size: 12px;
	color: #64748b;
}

.k-input-group input {
	width: 100%;
	height: 38px;
	border-radius: 4px;
	border: 1px solid #cbd5e1;
}

.k-code-input {
	font-family: monospace;
	background: #f8fafc;
	color: #0f172a;
	direction: ltr;
	text-align: left;
}

.remove-row {
	color: #ef4444 !important;
	border-color: #ef4444 !important;
	background: transparent !important;
}

/* Rescue Box */
.kabook-rescue-box {
	background: #fff3cd;
	border: 1px solid #ffeeba;
	color: #856404;
	padding: 20px;
	border-radius: 6px;
	margin-top: 30px;
}

.rescue-title {
	margin-top: 0;
	font-size: 15px;
	color: #856404;
}

.rescue-textarea {
	width: 100%;
	font-family: monospace;
	font-size: 12px;
	background: #fff;
	border: 1px solid #e0dba8;
	padding: 10px;
	margin-top: 10px;
	color: #555;
	border-radius: 4px;
}

.rescue-textarea:focus {
	outline: none;
	border-color: #d1c882;
}

/* New Pro Tip Box */
.kabook-pro-tip-box {
	background: #f0fdf4; /* Light green */
	border: 1px solid #bbf7d0;
	border-left: 4px solid #22c55e;
	padding: 15px;
	margin-bottom: 25px;
	border-radius: 4px;
	color: #166534;
}

.kabook-pro-tip-box strong {
	display: block;
	margin-bottom: 5px;
	font-size: 14px;
	color: #15803d;
}

.kabook-pro-tip-box code {
	background: rgba(255, 255, 255, 0.7);
	color: #15803d;
}
/* Kabook Modal & RTL  */
div.mce-window-head,
body.rtl div.mce-window-head {
    background: linear-gradient(135deg, #005bea 0%, #00c6fb 100%) !important;
    padding: 0 15px !important;
    height: 45px !important;
    min-height: 45px !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

div.mce-title,
body.rtl div.mce-title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    text-shadow: none !important;
    line-height: 45px !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    text-align: left !important;
}

body.rtl div.mce-title {
    text-align: right !important;
    padding-left: 30px !important;
    direction: rtl !important;
}

button.mce-close,
body.rtl button.mce-close {
    color: #fff !important;
    background: transparent !important;
    text-shadow: none !important;
    top: 50% !important;
    margin-top: -10px !important;
    opacity: 0.7;
    font-size: 16px !important;
}

button.mce-close:hover,
body.rtl button.mce-close:hover {
    opacity: 1;
    color: #fff !important;
}

body:not(.rtl) button.mce-close { 
    right: 15px !important; 
    left: auto !important; 
}

body.rtl button.mce-close { 
    left: 15px !important; 
    right: auto !important; 
}

div.mce-window {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25) !important;
}
/* ==========================================================================
   Kabook Modal Styling (Final Polish)
   Blue Header, RTL Text Alignment, Pure White Close Button
   ========================================================================== */

/* 1. Header Strip (Blue Harmony) */
div.mce-window-head,
body.rtl div.mce-window-head {
    background: linear-gradient(135deg, #005bea 0%, #00c6fb 100%) !important;
    padding: 0 15px !important;
    height: 45px !important;
    min-height: 45px !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* 2. Title Text (RTL & Alignment) */
div.mce-title,
body.rtl div.mce-title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    text-shadow: none !important;
    line-height: 45px !important;
    margin: 0 !important;
    padding: 0 !important;
    
    /* RTL Specifics */
    width: 100% !important;
    text-align: left !important;
}

/* RTL Override for Title */
body.rtl div.mce-title {
    text-align: right !important;
    padding-left: 30px !important; 
    direction: rtl !important;
}

/* 3. Close Button Container */
button.mce-close,
body.rtl button.mce-close {
    background: transparent !important;
    top: 50% !important;
    margin-top: -11px !important; 
    border: none !important;
    box-shadow: none !important;
}

/* === Target the Icon DIRECTLY === */
button.mce-close i,
button.mce-close .mce-ico,
body.rtl button.mce-close .mce-ico {
    color: #fff !important;       
    text-shadow: none !important;
    font-size: 16px !important;
    line-height: 22px !important; 
}

/* Hover Effect */
button.mce-close:hover {
    opacity: 1;
    transform: scale(1.1); 
}

/* 4. Position Logic (RTL vs LTR) */
/* LTR: Button on Right */
body:not(.rtl) button.mce-close { 
    right: 15px !important; 
    left: auto !important; 
}

/* RTL: Button on Left */
body.rtl button.mce-close { 
    left: 15px !important; 
    right: auto !important; 
}

/* 5. Window Body Rounded Corners */
div.mce-window {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25) !important;
}