/**
 * SheetMirror admin styles.
 *
 * @package SheetMirror
 */

/* ---------------------------------------------------------------------------
   CSS custom properties
--------------------------------------------------------------------------- */
:root {
	--sheetmirror-accent:    #2563eb;
	--sheetmirror-accent-dk: #1d4ed8;
	--sheetmirror-danger:    #dc2626;
	--sheetmirror-success:   #16a34a;
	--sheetmirror-warn:      #d97706;
	--sheetmirror-bg:        #f8fafc;
	--sheetmirror-card-bg:   #ffffff;
	--sheetmirror-border:    #e2e8f0;
	--sheetmirror-text:      #1e293b;
	--sheetmirror-muted:     #64748b;
	--sheetmirror-radius:    8px;
	--sheetmirror-shadow:    0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}

/* ---------------------------------------------------------------------------
   Page header
--------------------------------------------------------------------------- */
.wrap.sheetmirror-wrap { max-width: 1200px; }

.sheetmirror-page-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 22px;
	color: var(--sheetmirror-text);
}
.sheetmirror-page-title .dashicons {
	font-size: 24px;
	width: 24px;
	height: 24px;
	color: var(--sheetmirror-accent);
}

/* ---------------------------------------------------------------------------
   Layout
--------------------------------------------------------------------------- */
.sheetmirror-layout {
	display: grid;
	grid-template-columns: 400px 1fr;
	gap: 24px;
}
@media ( max-width: 900px ) {
	.sheetmirror-layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Cards
--------------------------------------------------------------------------- */
.sheetmirror-card {
	background: var(--sheetmirror-card-bg);
	border: 1px solid var(--sheetmirror-border);
	border-radius: var(--sheetmirror-radius);
	padding: 24px;
	box-shadow: var(--sheetmirror-shadow);
	margin-bottom: 24px;
}
.sheetmirror-card h2 {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 20px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--sheetmirror-border);
	font-size: 15px;
	color: var(--sheetmirror-text);
}
.sheetmirror-card h2 .dashicons {
	color: var(--sheetmirror-accent);
}

/* ---------------------------------------------------------------------------
   Form fields
--------------------------------------------------------------------------- */
.sheetmirror-field { margin-bottom: 18px; }

.sheetmirror-field label {
	display: block;
	font-weight: 600;
	font-size: 13px;
	color: var(--sheetmirror-text);
	margin-bottom: 6px;
}

.sheetmirror-required {
	color: var(--sheetmirror-danger);
	margin-left: 2px;
}

.sheetmirror-hint {
	display: block;
	font-size: 11px;
	font-weight: 400;
	color: var(--sheetmirror-muted);
	margin-top: 2px;
}

.sheetmirror-field input[type="text"],
.sheetmirror-field input[type="url"],
.sheetmirror-field input[type="password"] {
	width: 100%;
	padding: 9px 12px;
	border: 1.5px solid var(--sheetmirror-border);
	border-radius: 6px;
	font-size: 13px;
	transition: border-color .15s, box-shadow .15s;
	box-sizing: border-box;
	color: var(--sheetmirror-text);
}

.sheetmirror-field input:focus {
	outline: none;
	border-color: var(--sheetmirror-accent);
	box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.sheetmirror-field input[readonly] {
	background: var(--sheetmirror-bg);
	color: var(--sheetmirror-muted);
}

/* Tag preview */
.sheetmirror-tag-preview-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
}
.sheetmirror-tag-preview-wrap input { flex: 1; }
.sheetmirror-tag-preview {
	display: inline-block;
	background: #eff6ff;
	color: var(--sheetmirror-accent);
	border: 1.5px solid #bfdbfe;
	border-radius: 5px;
	padding: 5px 10px;
	font-size: 12px;
	font-family: monospace;
	white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Toggle switches
--------------------------------------------------------------------------- */
.sheetmirror-toggles {
	display: flex !important;
	flex-direction: column !important;
	gap: 10px !important;
}

.sheetmirror-toggle-label {
	display: block !important;
	position: relative !important;
	padding-left: 52px !important;
	min-height: 24px !important;
	line-height: 24px !important;
	cursor: pointer !important;
	font-size: 13px !important;
	font-weight: 500 !important;
	color: var(--sheetmirror-text) !important;
	margin: 0 !important;
	user-select: none;
}

/* Hide the native checkbox */
.sheetmirror-toggle-label input[type="checkbox"] {
	position: absolute !important;
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	pointer-events: none !important;
	clip: rect(0,0,0,0) !important;
	overflow: hidden !important;
}

/* Custom slider */
.sheetmirror-toggle-slider {
	position: absolute !important;
	left: 0 !important;
	top: 50% !important;
	transform: translateY(-50%) !important;
	width: 38px !important;
	height: 22px !important;
	background: #cbd5e1 !important;
	border-radius: 11px !important;
	transition: background .2s;
}
.sheetmirror-toggle-slider::after {
	content: '' !important;
	position: absolute !important;
	width: 16px !important;
	height: 16px !important;
	background: #fff !important;
	border-radius: 50% !important;
	top: 3px !important;
	left: 3px !important;
	transition: transform .2s;
	box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sheetmirror-toggle-label input:checked + .sheetmirror-toggle-slider {
	background: var(--sheetmirror-accent) !important;
}
.sheetmirror-toggle-label input:checked + .sheetmirror-toggle-slider::after {
	transform: translateY(0) translateX(16px) !important;
}

/* Hint text below a toggle */
.sheetmirror-api-hint {
	margin: 0 0 0 52px;
	font-size: 11px;
	color: var(--sheetmirror-muted);
	line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Form actions
--------------------------------------------------------------------------- */
.sheetmirror-form-actions {
	display: flex;
	gap: 10px;
	margin-top: 22px;
}

/* ---------------------------------------------------------------------------
   Connection test
--------------------------------------------------------------------------- */
.sheetmirror-test-area {
	display: none;
	align-items: center;
	gap: 12px;
	margin: 14px 0 4px;
}
.sheetmirror-test-area .button .dashicons {
	vertical-align: middle;
	margin-top: -2px;
}
.sheetmirror-test-msg {
	font-size: 12px;
}
.sheetmirror-test-ok {
	color: var(--sheetmirror-success);
	font-weight: 600;
}
.sheetmirror-test-error {
	color: var(--sheetmirror-danger);
	font-weight: 600;
}
.sheetmirror-test-icon {
	vertical-align: middle;
	margin-right: 4px;
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* ---------------------------------------------------------------------------
   API key section
--------------------------------------------------------------------------- */
.sheetmirror-apikey-row {
	display: flex;
	gap: 12px;
	align-items: flex-end;
}
.sheetmirror-field--grow { flex: 1; }
.sheetmirror-apikey-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
	padding-bottom: 1px;
}
.sheetmirror-apikey-ok {
	display: flex;
	align-items: center;
	gap: 4px;
	color: var(--sheetmirror-success);
	font-size: 13px;
	margin: 8px 0 0;
}
.sheetmirror-apikey-ok .dashicons { color: var(--sheetmirror-success); }
.sheetmirror-apikey-warn {
	display: flex;
	align-items: center;
	gap: 4px;
	color: var(--sheetmirror-warn);
	font-size: 13px;
	margin: 8px 0 0;
}
.sheetmirror-apikey-warn .dashicons { color: var(--sheetmirror-warn); }
.sheetmirror-guide-link {
	margin-top: 10px;
	font-size: 12px;
	color: var(--sheetmirror-muted);
}
.sheetmirror-guide-link a { color: var(--sheetmirror-accent); }

/* ---------------------------------------------------------------------------
   Table list
--------------------------------------------------------------------------- */
.sheetmirror-table-list {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.sheetmirror-table-item {
	border: 1.5px solid var(--sheetmirror-border);
	border-radius: var(--sheetmirror-radius);
	overflow: hidden;
	transition: box-shadow .15s;
}
.sheetmirror-table-item:hover {
	box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.sheetmirror-table-item-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #f1f5f9;
	padding: 10px 14px;
	border-bottom: 1px solid var(--sheetmirror-border);
}

.sheetmirror-table-tag {
	font-family: monospace;
	font-size: 14px;
	font-weight: 700;
	color: var(--sheetmirror-accent);
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	padding: 3px 9px;
	border-radius: 5px;
}

.sheetmirror-badges {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

/* .sheetmirror-badge */
.sheetmirror-badge {
	font-size: 10px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 20px;
}
.sheetmirror-badge-auto-w {
	background: #f0fdf4;
	color: #166534;
	border: 1px solid #bbf7d0;
}
.sheetmirror-badge-auto-s {
	background: #ecfdf5;
	color: #065f46;
	border: 1px solid #6ee7b7;
}
.sheetmirror-badge-header {
	background: #dcfce7;
	color: #166534;
	border: 1px solid #bbf7d0;
}
.sheetmirror-badge-borderless {
	background: #f1f5f9;
	color: #475569;
	border: 1px solid #cbd5e1;
}
.sheetmirror-badge-api {
	background: #ede9fe;
	color: #6d28d9;
	border: 1px solid #c4b5fd;
}
.sheetmirror-badge-csv {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #d1d5db;
}

.sheetmirror-table-item-body { padding: 10px 14px; }

.sheetmirror-meta {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	font-size: 12px;
	color: var(--sheetmirror-muted);
	margin-bottom: 4px;
}
.sheetmirror-meta .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	margin-top: 1px;
}
.sheetmirror-url-link {
	color: var(--sheetmirror-muted);
	text-decoration: none;
	word-break: break-all;
}
.sheetmirror-url-link:hover {
	color: var(--sheetmirror-accent);
	text-decoration: underline;
}
.sheetmirror-meta strong { color: var(--sheetmirror-text); }

.sheetmirror-table-item-actions {
	padding: 8px 14px;
	background: var(--sheetmirror-bg);
	border-top: 1px solid var(--sheetmirror-border);
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	align-items: center;
}
.sheetmirror-table-item-actions .button .dashicons {
	vertical-align: middle;
	margin-top: -2px;
	font-size: 14px;
	width: 14px;
	height: 14px;
}
.sheetmirror-btn-delete {
	color: var(--sheetmirror-danger) !important;
	border-color: var(--sheetmirror-danger) !important;
}
.sheetmirror-btn-delete:hover {
	background: var(--sheetmirror-danger) !important;
	color: #fff !important;
}

/* Empty state */
.sheetmirror-empty {
	text-align: center;
	padding: 40px 20px;
	color: var(--sheetmirror-muted);
}
.sheetmirror-empty p {
	font-size: 13px;
	line-height: 1.6;
}

/* ---------------------------------------------------------------------------
   Feature grid
--------------------------------------------------------------------------- */
.sheetmirror-format-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
	gap: 12px;
	margin-bottom: 16px;
}
.sheetmirror-format-item {
	background: var(--sheetmirror-bg);
	border: 1px solid var(--sheetmirror-border);
	border-radius: var(--sheetmirror-radius);
	padding: 12px;
	font-size: 13px;
	line-height: 1.5;
}
.sheetmirror-format-item small { color: var(--sheetmirror-muted); }

.sheetmirror-notice-box {
	background: #fffbeb;
	border: 1px solid #fde68a;
	border-radius: 6px;
	padding: 10px 14px;
	font-size: 12px;
	color: #78350f;
}

/* ---- Cell Padding collapsible ---- */
.sheetmirror-details-summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	font-size: 12px;
	color: var(--sheetmirror-muted, #6b7280);
	user-select: none;
	list-style: none;
	padding: 4px 0;
}
.sheetmirror-details-summary::-webkit-details-marker { display: none; }
.sheetmirror-details-summary::before {
	content: "▶";
	font-size: 10px;
	transition: transform 0.15s;
	display: inline-block;
}
.sheetmirror-details[open] > .sheetmirror-details-summary::before {
	transform: rotate(90deg);
}
.sheetmirror-details-summary .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
}

/* ---- gid field disabled state (API mode ON) ---- */
.sheetmirror-field--disabled {
	opacity: 0.45;
	pointer-events: none;
}
.sheetmirror-field--disabled input {
	background: #f1f5f9;
	color: #94a3b8;
	cursor: not-allowed;
}

/* ---- Toggle disabled state ---- */
.sheetmirror-toggle-disabled {
	opacity: 0.4;
	pointer-events: none;
	cursor: not-allowed !important;
}
.sheetmirror-toggle-disabled .sheetmirror-toggle-slider {
	background: #cbd5e1 !important;
}
