/* GNOME CSD styles for headerbar on Firefox [tabsintitlebar] */

@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

#main-window {
	-moz-appearance: -moz-window-titlebar !important;
}

/* Headerbar top border corners rounded */
:root[tabsintitlebar][sizemode="normal"]:not([gtktiledwindow="true"]) #nav-bar {
	border-radius: env(-moz-gtk-csd-titlebar-radius) env(-moz-gtk-csd-titlebar-radius) 0 0 !important;
}

/* Window buttons: at least 1 button */
@media (-moz-gtk-csd-minimize-button), (-moz-gtk-csd-maximize-button), (-moz-gtk-csd-close-button) {
	:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
		padding-right: 50px !important;
	}
}
/* Window buttons: at least 2 buttons */
@media (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-maximize-button),
       (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-close-button),
       (-moz-gtk-csd-maximize-button) and (-moz-gtk-csd-close-button) {
	:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
		padding-right: 90px !important;
	}
}
/* Window buttons: 3 buttons */
@media (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-maximize-button) and (-moz-gtk-csd-close-button) {
	:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
		padding-right: 130px !important;
	}
}

/* Left window buttons */
@media (-moz-gtk-csd-reversed-placement) {
	:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
		padding-right: 3px !important;
	}
	
	/* Window buttons box */
	:root[tabsintitlebar] #titlebar .titlebar-buttonbox-container {
		left: 9px;
		right: auto !important;
	}

	/* Window controls: at least 1 button */
	@media (-moz-gtk-csd-minimize-button), (-moz-gtk-csd-maximize-button), (-moz-gtk-csd-close-button) {
		:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
			padding-left: 50px !important;
		}
	}
	/* Window controls: at least 2 buttons */
	@media (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-maximize-button),
				 (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-close-button),
				 (-moz-gtk-csd-maximize-button) and (-moz-gtk-csd-close-button) {
		:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
			padding-left: 90px !important;
		}
	}
	/* Window controls: 3 buttons */
	@media (-moz-gtk-csd-minimize-button) and (-moz-gtk-csd-maximize-button) and (-moz-gtk-csd-close-button) {
		:root[tabsintitlebar]:not([inFullscreen]) #nav-bar {
			padding-left: 130px !important;
		}
	} 
}

/* Fullscreen headerbar padding for 1 button */
:root[tabsintitlebar][inFullscreen] #nav-bar {
	padding-right: 50px !important;
}

/* Remove close and minimize buttons from fullscreen buttons */
:root[tabsintitlebar][inFullscreen] #window-controls #close-button,
:root[tabsintitlebar][inFullscreen] #window-controls #minimize-button,
:root[tabsintitlebar][inFullscreen] #titlebar .titlebar-buttonbox-container .titlebar-min,
:root[tabsintitlebar][inFullscreen] #titlebar .titlebar-buttonbox-container .titlebar-close {
	display: none !important;
}

/* Remove tabsbar titlebar blank spaces */
:root[tabsintitlebar] #TabsToolbar .titlebar-placeholder {
	display: none !important;
}

/* Prevent menubar from breaking */
:root[tabsintitlebar] #toolbar-menubar:not([inactive=true]) {
	height: 30px !important;
	margin-bottom: 8px;
}

/* Remove default style of titlebar */
:root[tabsintitlebar] #titlebar {
	-moz-appearance: none !important;
}

/* Fix the issue when dragging tabs */
:root[tabsintitlebar] #navigator-toolbox[movingtab] #TabsToolbar {
	padding-bottom: 0 !important;
}

/* Window buttons box */
:root[tabsintitlebar] #titlebar .titlebar-buttonbox-container,
:root[tabsintitlebar] #titlebar-buttonbox-container,
:root[tabsintitlebar][inFullscreen] #window-controls {
	-moz-appearance: none !important;
	padding: 6px 10px 6px 0;
	position: absolute !important;
	right: 0;
	top: 0;
	display: block !important;
}
:root[tabsintitlebar] #titlebar .titlebar-buttonbox {
	-moz-appearance: none !important;
}

/* Window buttons style */
:root[tabsintitlebar] #titlebar .titlebar-button,
:root[tabsintitlebar][inFullscreen] #window-controls toolbarbutton {
	-moz-appearance: none !important;
	padding: 0 !important;
}

:root[tabsintitlebar] #titlebar .titlebar-button {
	border-radius: 100% !important;
	height: 16px !important;
	margin: 10px 7px !important;
	width: 16px !important;
}

:root[tabsintitlebar][inFullscreen] #titlebar .titlebar-button,
:root[tabsintitlebar][inFullscreen] #window-controls toolbarbutton {
	border-radius: 6px !important;
	height: 32px !important;
	margin: 0 4px !important;
	width: 32px !important;
}

:root[tabsintitlebar] #titlebar toolbarbutton > .toolbarbutton-icon {
	padding: 0 !important;
	stroke: none !important;
	-moz-context-properties: fill, fill-opacity !important;
}

:root[tabsintitlebar] #titlebar .titlebar-button .toolbarbutton-icon,
:root[tabsintitlebar][inFullscreen] #window-controls toolbarbutton .toolbarbutton-icon {
	width: 16px;
}
:root[tabsintitlebar] #titlebar:-moz-window-inactive .titlebar-button,
:root[tabsintitlebar][inFullscreen] #window-controls:-moz-window-inactive toolbarbutton {
	opacity: .3 !important;
}

:root[tabsintitlebar] #titlebar .titlebar-min,
:root[tabsintitlebar] #titlebar #titlebar-min {
	background: var(--gnome-titlebutton-min-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-restore,
:root[tabsintitlebar] #titlebar .titlebar-max,
:root[tabsintitlebar] #titlebar #titlebar-max {
	background: var(--gnome-titlebutton-max-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-close,
:root[tabsintitlebar] #titlebar #titlebar-close {
	background: var(--gnome-titlebutton-close-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-min:hover,
:root[tabsintitlebar] #titlebar #titlebar-min:hover {
	background: var(--gnome-titlebutton-min-hover-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-restore:hover,
:root[tabsintitlebar] #titlebar .titlebar-max:hover,
:root[tabsintitlebar] #titlebar #titlebar-max:hover {
	background: var(--gnome-titlebutton-max-hover-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-close:hover,
:root[tabsintitlebar] #titlebar #titlebar-close:hover {
	background: var(--gnome-titlebutton-close-hover-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-min:active,
:root[tabsintitlebar] #titlebar #titlebar-min:active {
	background: var(--gnome-titlebutton-min-active-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-restore:active,
:root[tabsintitlebar] #titlebar .titlebar-max:active,
:root[tabsintitlebar] #titlebar #titlebar-max:active {
	background: var(--gnome-titlebutton-max-active-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-close:active,
:root[tabsintitlebar] #titlebar #titlebar-close:active {
	background: var(--gnome-titlebutton-close-active-background) !important;
}

:root[tabsintitlebar] #titlebar .titlebar-button:not(:hover):not(:active) .toolbarbutton-icon {
	list-style-image: none !important;
	filter: none !important;
	fill: transparent !important;
	color: transparent !important;
}

:root[tabsintitlebar] #titlebar .titlebar-button:hover .toolbarbutton-icon,
:root[tabsintitlebar] #titlebar .titlebar-button:active .toolbarbutton-icon {
	filter: invert(100%) brightness(200%) !important;
}

/* OPTIONAL: Allow draging the window from headerbar buttons */
@supports -moz-bool-pref("gnomeTheme.dragWindowHeaderbarButtons") {
	:root[tabsintitlebar] #nav-bar *,
	:root[tabsintitlebar] #titlebar .titlebar-button,
	:root[tabsintitlebar][inFullscreen] #window-controls toolbarbutton {
		-moz-window-dragging: drag;
	}
	
	/* Avoid window dragging from urlbar */
	:root[tabsintitlebar] #nav-bar .urlbar-input-box,
	:root[tabsintitlebar] #nav-bar .urlbar-input-box * {
		-moz-window-dragging: no-drag !important;
	}
}
