/**
 * Shared Table Styles
 *
 * Usage: @import url('/assets/styles/tables.css');
 *
 * Table variants:
 *   .data-table              - Base table styling
 *   .data-table--striped     - Alternating row colors
 *   .data-table--compact     - Reduced padding
 *   .data-table--bordered    - Cell borders
 *   .data-table--hoverable   - Row hover effect
 *
 * Utility classes:
 *   .table-scroll            - Responsive horizontal scroll wrapper
 *   .cell-mono               - Monospace text (for code)
 *   .cell-nowrap             - Prevent wrapping
 *   .cell-center             - Center align
 *   .cell-right              - Right align
 *   .cell-muted              - Dimmed text
 *
 * Status badges:
 *   .badge                   - Base badge
 *   .badge--success/warning/error/info/neutral
 */

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

.data-table {
	--table-bg: white;
	--table-border: var(--color-border, #e5e7eb);
	--table-header-bg: var(--color-gray-50, #f9fafb);
	--table-header-color: var(--color-gray-700, #374151);
	--table-cell-padding: 0.875rem 1rem;
	--table-font-size: 0.9375rem;
	--table-radius: var(--radius-3, 0.5rem);
	--table-hover-bg: var(--color-gray-50, #f9fafb);

	width: 100%;
	border-collapse: collapse;
	background: var(--table-bg);
	border-radius: var(--table-radius);
	overflow: hidden;
	box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
	font-size: var(--table-font-size);
	margin: var(--size-6, 1.5rem) 0;
}

/* Header */
.data-table thead {
	background: var(--table-header-bg);
	border-bottom: 2px solid var(--table-border);
}

.data-table th {
	padding: var(--table-cell-padding);
	text-align: left;
	font-weight: 600;
	font-size: 0.8125rem;
	color: var(--table-header-color);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
}

/* Cells */
.data-table td {
	padding: var(--table-cell-padding);
	border-bottom: 1px solid var(--table-border);
	vertical-align: top;
	line-height: 1.5;
}

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

/* Code in tables */
.data-table code {
	background: var(--color-gray-100, #f3f4f6);
	color: var(--color-gray-800, #1f2937);
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-size: 0.875em;
	font-family: var(--font-mono, 'Monaco', 'Consolas', monospace);
	font-weight: 500;
	word-break: break-word;
}

/* Links in tables */
.data-table a:not(.badge) {
	color: var(--color-primary, #14b8a6);
	text-decoration: none;
}

.data-table a:not(.badge):hover {
	text-decoration: underline;
}


/* =============================================================================
   Table Variants
   ============================================================================= */

/* Striped rows */
.data-table--striped tbody tr:nth-child(even) {
	background: var(--color-gray-50, #f9fafb);
}

/* Hoverable rows */
.data-table--hoverable tbody tr {
	transition: background-color 0.15s ease;
}

.data-table--hoverable tbody tr:hover {
	background: var(--table-hover-bg);
}

/* Compact variant */
.data-table--compact {
	--table-cell-padding: 0.5rem 0.75rem;
	--table-font-size: 0.875rem;
}

/* Bordered cells */
.data-table--bordered td,
.data-table--bordered th {
	border: 1px solid var(--table-border);
}

/* First column emphasis */
.data-table--first-col-emphasis td:first-child {
	font-weight: 600;
	color: var(--color-gray-800, #1f2937);
}


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

.table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: var(--size-6, 1.5rem) 0;
}

.table-scroll .data-table {
	margin: 0;
	min-width: 600px;
}

/* Scroll hint shadow */
.table-scroll {
	position: relative;
}

.table-scroll::after {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 30px;
	background: linear-gradient(to right, transparent, rgb(0 0 0 / 0.03));
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.table-scroll:not(:has(::-webkit-scrollbar-thumb:hover))::after {
	opacity: 1;
}


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

.cell-mono {
	font-family: var(--font-mono, 'Monaco', 'Consolas', monospace);
	font-size: 0.875em;
}

.cell-nowrap {
	white-space: nowrap;
}

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

.cell-right {
	text-align: right;
}

.cell-muted {
	color: var(--color-gray-500, #6b7280);
	font-size: 0.875em;
}

.cell-wide {
	min-width: 200px;
}

.cell-narrow {
	width: 1%;
	white-space: nowrap;
}


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

.badge {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.25rem 0.625rem;
	border-radius: 9999px;
	font-size: 0.6875rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
	text-decoration: none;
}

.badge::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	flex-shrink: 0;
}

/* Success - Green */
.badge--success {
	background: #dcfce7;
	color: #166534;
}
.badge--success::before {
	background: #166534;
}

/* Warning - Amber */
.badge--warning {
	background: #fef3c7;
	color: #92400e;
}
.badge--warning::before {
	background: #92400e;
}

/* Error - Red */
.badge--error {
	background: #fee2e2;
	color: #991b1b;
}
.badge--error::before {
	background: #991b1b;
}

/* Info - Teal (matches primary) */
.badge--info {
	background: #ccfbf1;
	color: #0f766e;
}
.badge--info::before {
	background: #0f766e;
}

/* Neutral - Gray */
.badge--neutral {
	background: #e5e7eb;
	color: #374151;
}
.badge--neutral::before {
	background: #374151;
}

/* Deprecated - Orange-Red */
.badge--deprecated {
	background: #fed7aa;
	color: #9a3412;
}
.badge--deprecated::before {
	background: #9a3412;
}


/* =============================================================================
   Diagrams & Visual Elements
   ============================================================================= */

.diagram {
	background: var(--color-gray-50, #f9fafb);
	border: 1px solid var(--color-border, #e5e7eb);
	border-radius: var(--radius-3, 0.5rem);
	padding: var(--size-6, 1.5rem);
	margin: var(--size-6, 1.5rem) 0;
	overflow-x: auto;
}

.diagram pre {
	margin: 0;
	background: transparent;
	color: var(--color-gray-700, #374151);
	font-family: var(--font-mono, 'Monaco', 'Consolas', monospace);
	font-size: 0.875rem;
	line-height: 1.5;
	white-space: pre;
}

.diagram figcaption {
	margin-top: var(--size-4, 1rem);
	font-size: 0.875rem;
	color: var(--color-gray-600, #4b5563);
	text-align: center;
	font-style: italic;
}

/* URL anatomy diagram specific */
.url-diagram {
	font-family: var(--font-mono, 'Monaco', 'Consolas', monospace);
	font-size: 1rem;
	line-height: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	justify-content: center;
	align-items: flex-start;
	padding: var(--size-4, 1rem) 0;
}

.url-diagram .part {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
}

.url-diagram .part-value {
	padding: 0.25rem 0.5rem;
	border-radius: 0.25rem;
	font-weight: 500;
}

.url-diagram .part-label {
	font-size: 0.6875rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-gray-500, #6b7280);
	margin-top: 0.25rem;
	font-family: var(--font-sans, system-ui, sans-serif);
}

.url-diagram .scheme { background: #fef3c7; color: #92400e; }
.url-diagram .authority { background: #dbeafe; color: #1e40af; }
.url-diagram .host { background: #dcfce7; color: #166534; }
.url-diagram .port { background: #f3e8ff; color: #6b21a8; }
.url-diagram .path { background: #e0e7ff; color: #3730a3; }
.url-diagram .query { background: #fce7f3; color: #9d174d; }
.url-diagram .fragment { background: #ffedd5; color: #9a3412; }
.url-diagram .separator { color: var(--color-gray-400, #9ca3af); }


/* =============================================================================
   Definition Lists (for reference content)
   ============================================================================= */

.def-list {
	margin: var(--size-6, 1.5rem) 0;
}

.def-list dt {
	font-weight: 600;
	color: var(--color-gray-800, #1f2937);
	margin-top: var(--size-4, 1rem);
	font-size: 1rem;
}

.def-list dt:first-child {
	margin-top: 0;
}

.def-list dt code {
	background: var(--color-gray-100, #f3f4f6);
	padding: 0.125rem 0.5rem;
	border-radius: 0.25rem;
	font-size: 0.9375em;
}

.def-list dd {
	margin: 0.25rem 0 0 0;
	padding-left: var(--size-4, 1rem);
	color: var(--color-gray-600, #4b5563);
	line-height: 1.6;
}

.def-list dd code {
	background: var(--color-gray-100, #f3f4f6);
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-size: 0.875em;
	font-family: var(--font-mono, monospace);
}


/* =============================================================================
   Key-Value Display
   ============================================================================= */

.kv-table {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.5rem 1rem;
	margin: var(--size-4, 1rem) 0;
	font-size: 0.9375rem;
}

.kv-table dt {
	font-weight: 600;
	color: var(--color-gray-700, #374151);
	text-align: right;
}

.kv-table dd {
	margin: 0;
	color: var(--color-gray-600, #4b5563);
}

.kv-table dd code {
	background: var(--color-gray-100, #f3f4f6);
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-family: var(--font-mono, monospace);
	font-size: 0.875em;
}


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

@media (max-width: 768px) {
	.data-table {
		--table-cell-padding: 0.625rem 0.75rem;
		--table-font-size: 0.875rem;
	}

	.data-table th {
		font-size: 0.75rem;
	}

	/* Stack key-value on mobile */
	.kv-table {
		grid-template-columns: 1fr;
		gap: 0.25rem;
	}

	.kv-table dt {
		text-align: left;
	}

	.kv-table dd {
		padding-bottom: 0.75rem;
		border-bottom: 1px solid var(--color-border, #e5e7eb);
	}

	.kv-table dd:last-child {
		border-bottom: none;
		padding-bottom: 0;
	}

	/* URL diagram responsive */
	.url-diagram {
		flex-direction: column;
		align-items: stretch;
	}

	.url-diagram .part {
		flex-direction: row;
		justify-content: space-between;
		padding: 0.5rem 0;
		border-bottom: 1px solid var(--color-border, #e5e7eb);
	}

	.url-diagram .part:last-child {
		border-bottom: none;
	}

	.url-diagram .part-label {
		margin-top: 0;
		order: -1;
	}
}
