/* TPM Custom Branding & Styling for DW23 Integration Theme */
/* This file integrates TPM's MCT visual identity with DW23IT */

/* Import Google Fonts for Poppins and Inter (Roboto already available in System) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&family=Poppins:wght@300;400;500;700&display=swap');

/* MCT Script Injection - Load MCT functionality */
/* This ensures MCT scripts load on all pages */

:root {
	/* TPM Color Scheme */
	--tpm-primary: #000000;
	--tpm-secondary: #00AEEF;
	--tpm-sidebar-bg: #292929;
	--tpm-sidebar-text: #ffffff;
	--tpm-project-card-bg: #efeeed;
	
	/* Override DW23IT color variables */
	--color-primary: var(--tpm-primary);
	--color-secondary: var(--tpm-secondary);
	
	/* Override navigation/sidebar colors - IMPORTANT to override appearance endpoint */
	--color-navigation-background: var(--tpm-sidebar-bg) !important;
	--color-navigation-text: var(--tpm-sidebar-text) !important;
	--color-navigation-item-text: var(--tpm-sidebar-text) !important;
	--color-navigation-item-text-hover: var(--tpm-sidebar-text) !important;
	--color-navigation-item-text-current: var(--tpm-sidebar-text) !important;
	--color-navigation-item-background-hover: rgba(255, 255, 255, 0.1) !important;
	--color-navigation-item-background-current: rgba(255, 255, 255, 0.15) !important;
	
	/* Light mode sidebar colors - TPM palette */
	--tpm-sidebar-light-bg: #f8f9fa;
	--tpm-sidebar-light-text: #2c3e50;
	--tpm-sidebar-light-hover: #e9ecef;
	--tpm-sidebar-light-current: #dee2e6;
	
	/* TPM Typography */
	--font-primary: 'Poppins', Arial, sans-serif;
	--font-heading: 'Inter', Arial, sans-serif;
	--font-caption: 'Roboto', Arial, sans-serif;
	
	/* TPM Sizing */
	--tpm-button-radius: 2rem;
	--tpm-input-radius: 10pt;
	--tpm-sidebar-width: 18em;
	--navigation-menu-width: var(--tpm-sidebar-width);
	
	/* Override existing button variables */
	--border-radius-button: var(--tpm-button-radius);
	--border-radius-input: var(--tpm-input-radius);
}

/* Typography - Apply Poppins as primary font */
body {
	font-family: var(--font-primary);
	font-size: 12pt;
	line-height: 1.8;
}

/* Headings - Apply Inter font */
h1, h2, h3, h4, h5, h6 {
	font-family: var(--font-heading);
	font-weight: bold;
	line-height: 1.2;
}

h1 {
	font-size: 48pt;
}

/* Captions and small text - Roboto */
.caption, small, .small-text {
	font-family: var(--font-caption);
	font-weight: 300;
}

/* Navigation Menu / Sidebar Styling */
/* Note: Sidebar colors are now controlled by Appearance.json */
/* Light mode: Light gray (#e8e8e8) with dark text */
/* Dark mode: Dark background (#1a1a1a) with light text */

/* Logo sizing */
.logo-image {
	width: 50%;
	max-width: 200px;
	padding: 1em;
}

/* Button Styling - TPM rounded buttons */
button,
.button,
.button-primary,
.button-secondary {
	border-radius: var(--tpm-button-radius);
	background-color: var(--tpm-secondary);
	color: white;
	border: none;
}

button:hover,
.button:hover,
.button-primary:hover {
	background-color: rgb(36, 58, 118);
	color: white;
}

/* Input Styling */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
	border-radius: var(--tpm-input-radius);
}

/* Login Form Styling - Force dark mode support */
:root.dark .login-content {
	background-color: var(--color-login-background) !important;
	color: var(--color-login-text) !important;
}

:root.dark .login-form-container {
	padding: 1em;
	background-color: var(--color-login-background) !important;
	color: var(--color-login-text) !important;
}

/* Light mode login styling */
:root.light .login-content {
	background-color: var(--color-login-background) !important;
	color: var(--color-login-text) !important;
}

:root.light .login-form-container {
	padding: 1em;
	background-color: var(--color-login-background) !important;
	color: var(--color-login-text) !important;
}

/* Project Cards - TPM styling */
.project-card,
.grid-card {
	background-color: var(--tpm-project-card-bg);
	margin: 22px;
}

.drive-app-card {
	background-color: var(--tpm-project-card-bg);
	margin: 22px;
}

/* Focus states */
*:focus,
*:focus-visible {
	outline-color: var(--tpm-secondary);
}

/* Links */
a {
	color: var(--tpm-secondary);
}

a:hover {
	color: var(--tpm-primary);
}

/* Header styling - ensure proper spacing */
.page-header {
	background-color: white;
	color: black;
	min-height: var(--header-height);
	padding: var(--spacing-lg);
}

/* Icon colors - ensure visibility on buttons */
button svg,
.button svg,
.button-primary svg {
	color: white;
	fill: currentColor;
}

/* Icon colors on secondary/transparent buttons */
.button-secondary svg,
.button-default svg,
.button-ghost svg {
	color: inherit;
}

/* Ensure icons in blue buttons are white */
button[class*="primary"] svg,
.button-primary svg {
	color: white !important;
	fill: white !important;
}

/* Secondary color applications */
.button-secondary,
.icon-button:hover {
	background-color: var(--tpm-secondary);
}

/* Copyright Footer - MCT Feature */
.copyright-footer {
	text-align: center;
	padding: 1em;
	color: #666;
	font-size: 0.9em;
	border-top: 1px solid #eee;
	margin-top: 2em;
}

/* MCT Watermark - Original Sizing and Positioning */
.mct-watermark {
	position: absolute;
	bottom: 8%;
	left: 0;
	right: 0;
	height: 50px;
	font-size: 50px;
	text-align: center;
	color: rgba(112, 112, 112, 0.5);
	text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.4);
	pointer-events: none;
	user-select: none;
	z-index: 2;
}

/* Sideways watermark for run.html pages */
.mct-watermark.sideways {
	writing-mode: vertical-lr;
	left: unset;
	right: 10px;
	width: 50px;
	height: unset;
}

/* Banner - MCT Feature */
.mct-banner {
	background-color: var(--tpm-secondary);
	color: white;
	padding: 1em;
	text-align: center;
	font-weight: 500;
	position: sticky;
	top: 0;
	z-index: 1000;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mct-banner a {
	color: white;
	text-decoration: underline;
}

.mct-banner a:hover {
	color: #f0f0f0;
}

/* Login Carousel - MCT Feature */
.login-cover {
	position: relative;
	overflow: hidden;
}

.carousel-image {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 1s ease-in-out;
}

.carousel-image.active {
	opacity: 1;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
	:root {
		--tpm-sidebar-width: 100%;
	}
	
	h1 {
		font-size: 32pt;
	}
	
	.project-card,
	.grid-card,
	.drive-app-card {
		margin: 12px;
	}
}

/* Dark mode support - maintain TPM colors */
:root.dark {
	--color-primary: var(--tpm-primary);
	--color-secondary: var(--tpm-secondary);
}

/* Ensure buttons maintain TPM branding in dark mode */
:root.dark button,
:root.dark .button-primary {
	background-color: var(--tpm-secondary);
	color: white;
}

:root.dark button:hover,
:root.dark .button-primary:hover {
	background-color: rgb(36, 58, 118);
}

/* Settings page - maintain TPM branding */
.page-content input[type="color"] {
	border-radius: var(--tpm-input-radius);
}

/* History and details pages */
.history-content,
.detail-inner {
	font-family: var(--font-primary);
}

.state-tag {
	border-radius: calc(var(--tpm-button-radius) / 2);
}

/* Specification properties */
.property-item {
	font-family: var(--font-primary);
}

/* Loading states */
dw-live-loading-spinner {
	color: var(--tpm-secondary);
}

/* Ensure all form inputs have consistent styling */
form input,
form textarea,
form select {
	border-radius: var(--tpm-input-radius);
	font-family: var(--font-primary);
}

/* Project and DriveApp titles */
.project-title,
.drive-app-content h3 {
	font-family: var(--font-heading);
	color: var(--tpm-primary);
}

/* Make sure TPM secondary color is used for interactive elements */
.button-confirm,
.button-info {
	background-color: var(--tpm-secondary);
}

.button-confirm:hover,
.button-info:hover {
	background-color: rgb(36, 58, 118);
}

/* MCT Script Injection - Load MCT functionality on all pages */
/* This ensures MCT scripts load even when custom HTML files aren't served */

/* Inject MCT loader script */
body::before {
    content: '';
    display: none;
}

/* Add MCT script injection via CSS */
@supports (content: '') {
    body::after {
        content: '';
        display: none;
    }
}

/* Fix Color Scheme Selector Icon Visibility in Light Mode */
/* Ensure icons are visible in light theme */
.color-scheme-popout button.color-scheme-option img,
.color-scheme-popout button.color-scheme-option svg {
    filter: brightness(0) saturate(100%);
}

/* Light mode specific fixes */
.light .color-scheme-popout button.color-scheme-option img,
.light .color-scheme-popout button.color-scheme-option svg,
html.light .color-scheme-popout button.color-scheme-option img,
html.light .color-scheme-popout button.color-scheme-option svg {
    filter: brightness(0) saturate(100%) invert(0%);
    opacity: 0.8;
}

/* Dark mode specific fixes */
.dark .color-scheme-popout button.color-scheme-option img,
.dark .color-scheme-popout button.color-scheme-option svg,
html.dark .color-scheme-popout button.color-scheme-option img,
html.dark .color-scheme-popout button.color-scheme-option svg {
    filter: brightness(0) saturate(100%) invert(100%);
    opacity: 0.9;
}

/* Hover states for better visibility */
.color-scheme-popout button.color-scheme-option:hover img,
.color-scheme-popout button.color-scheme-option:hover svg {
    opacity: 1;
}

/* Focus states for accessibility */
.color-scheme-popout button.color-scheme-option:focus-visible img,
.color-scheme-popout button.color-scheme-option:focus-visible svg {
    opacity: 1;
    filter: brightness(0) saturate(100%) invert(0%) drop-shadow(0 0 2px var(--color-outline-focus));
}

/* Additional fixes for any remaining white-on-white icon issues */
/* Target all possible icon containers in light mode */
.light img[src*="icon"],
.light svg,
html.light img[src*="icon"],
html.light svg {
    filter: brightness(0) saturate(100%);
}

/* Ensure navigation icons are visible */
.light .navigation img,
.light .navigation svg,
html.light .navigation img,
html.light .navigation svg {
    filter: brightness(0) saturate(100%);
    opacity: 0.8;
}

/* Fix any button icons in light mode */
.light button img,
.light button svg,
html.light button img,
html.light button svg {
    filter: brightness(0) saturate(100%);
}

/* Ensure proper contrast for all icons in light mode */
.light *[class*="icon"] img,
.light *[class*="icon"] svg,
html.light *[class*="icon"] img,
html.light *[class*="icon"] svg {
    filter: brightness(0) saturate(100%);
    opacity: 0.8;
}

/* Light Mode Sidebar Styling - TPM Palette */
/* Override sidebar colors for light mode */
.light .navigation,
html.light .navigation,
.light dw-live-navigation-menu,
html.light dw-live-navigation-menu {
    background-color: var(--tpm-sidebar-light-bg) !important;
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode navigation text */
.light .navigation *,
html.light .navigation *,
.light dw-live-navigation-menu *,
html.light dw-live-navigation-menu * {
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode navigation links */
.light .navigation a,
html.light .navigation a,
.light dw-live-navigation-menu a,
html.light dw-live-navigation-menu a {
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode navigation link hover */
.light .navigation a:hover,
html.light .navigation a:hover,
.light dw-live-navigation-menu a:hover,
html.light dw-live-navigation-menu a:hover {
    background-color: var(--tpm-sidebar-light-hover) !important;
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode current/active navigation item */
.light .navigation a[aria-current="page"],
html.light .navigation a[aria-current="page"],
.light dw-live-navigation-menu a[aria-current="page"],
html.light dw-live-navigation-menu a[aria-current="page"],
.light .navigation .current,
html.light .navigation .current,
.light dw-live-navigation-menu .current,
html.light dw-live-navigation-menu .current {
    background-color: var(--tpm-sidebar-light-current) !important;
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode navigation icons */
.light .navigation img,
.light .navigation svg,
html.light .navigation img,
html.light .navigation svg,
.light dw-live-navigation-menu img,
.light dw-live-navigation-menu svg,
html.light dw-live-navigation-menu img,
html.light dw-live-navigation-menu svg {
    filter: brightness(0) saturate(100%) !important;
    opacity: 0.8 !important;
}

/* Light mode user info section */
.light .navigation .user-info,
html.light .navigation .user-info,
.light dw-live-navigation-menu .user-info,
html.light dw-live-navigation-menu .user-info {
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode buttons in sidebar */
.light .navigation button,
html.light .navigation button,
.light dw-live-navigation-menu button,
html.light dw-live-navigation-menu button {
    color: var(--tpm-sidebar-light-text) !important;
}

/* Light mode button icons in sidebar */
.light .navigation button img,
.light .navigation button svg,
html.light .navigation button img,
html.light .navigation button svg,
.light dw-live-navigation-menu button img,
.light dw-live-navigation-menu button svg,
html.light dw-live-navigation-menu button img,
html.light dw-live-navigation-menu button svg {
    filter: brightness(0) saturate(100%) !important;
    opacity: 0.8 !important;
}
